thomas4019 / expressa

API creation middleware with an admin interface
MIT License
439 stars 27 forks source link

cacheInMemory with Redis #176

Open kane-mason opened 2 years ago

kane-mason commented 2 years ago

I know expressa does have a memory cache for the storage types.. I have not tested used it or seen it used with anything other than the roles collection. I also noticed a unit test that fails when you set cacheInMemory: true so dont have huge confidence in it? Also what if you have more than one instance of your app running?

Anyway, i was researching it a bit, and i thought there may be an opportunity to cacheInMemory with redis? Since all the complexities around data consistency, transaction concurrency and instancing are taken care of?

thomas4019 commented 2 years ago

Yes, cacheInMemory: true is not intended for models which change frequently. It generally works fine for models that very rarely change like settings or collections. In cases of when you're running multiple instances, rebooting all instances is recommended after changing any data that uses cacheInMemory: true.

Having the option of a redis cache seems like a good idea to me! It probably wouldn't quite replace the in-memory cache, but would be helpful in many cases.

Are you running into performance constraints without caching or just wanting to consider scalability?

kane-mason commented 2 years ago

no not running into performance problems yet, but just trying to think of the future and something like redis seems to be commonly done and i thought there may be an oppurtunity for it to fit in nicely here! I am no expert on it though..

thomas4019 commented 2 years ago

Makes sense! I think this would be a nice feature too, but I think we should implement once we see a need