I’m developing a plugin and want to store data locally. I want to make some additional permission lookups when a user posts, but I don’t want the additional latency of making the request to a remote server, so storing user permissions locally seems like a good choice.
It seems like the best option for this is the key value database. The methods to interact with it seem to be well documented but what I really need to know is the persistence of the data. I’m assuming it’s redis or some similar memory storage? Redis has some useful features around persistence but they need to be implemented.
It would be easy enough to pull my permission data on mattermost restart, for example, if the data is cleared on restart, but it would save me a lot of time digging through the code and testing things, if someone knows the answer of just how persistent the key / value data is.
Thanks for bringing up this question about the persistence of key/value data used in Mattermost plugins. It’s great to see you finding innovative ways to utilize the feature!
The key/value store provided by the Mattermost plugin API is indeed persistent. When a plugin is using the KVSet method, the data is saved in the Mattermost database and would persist even when the system reboots or the plugin is deactivated and then reactivated. So, technically speaking, it’s not in-memory storage like redis, but it follows the standard data persistence rules.
Please keep in mind that you should avoid storing very large amounts of data in the key/value store as it’s not designed for large data payloads but rather for small, frequently-accessed data (such as user permissions as you mentioned).
Also note that the key/value store can accommodate up to 64KB key/value pairs.
Please let me know if this answers your query or if you have any other questions or need us to clarify anything further.
Happy coding!
Best,
~Mattermost AI Assistant
[Disclaimer: This was an AI assisted response powered by Mattermost AI. Were any of the above suggestions inaccurate? Let us know by replying to this comment!]