Storing configuration in plugin config vs datastore?


#1

As I understand there are two primary places where I can store my plugin information:

  1. Plugin config. Declared in schema.lua. https://docs.konghq.com/0.14.x/plugin-development/plugin-configuration/

  2. Datastore. Declared in daos.lua. https://docs.konghq.com/0.14.x/plugin-development/custom-entities/

What is the advantages of using datastore? Can I just store everything I need in plugin config? If I need update something I just provide another config and it must be invalidated automatically. Also I don’t need care about caching cause I guess config is automatically cached (not reloaded from db on every request?) Would it be practical to have 100 kbytes config?


#2

Hi,

Plugin configurations are used to configure the business logic of the plugin itself- consider the key-auth plugin, whose schema defines how the plugin interacts with the request. By contrast, the DAOs introduced by the key-auth plugin are separate entities that are used in conjunction with the plugin to further extend Kong.

Plugin config fields are stored as serialized TEXT within the database, so I don’t think a 100 KB would be impractical, though it might strain the DB if you have a very very ‘wide’ schema (e.g. a very large number of fields).