I am learning about caching and wanted guidance on what is the best strategy for caching static data.
I have some metadata that I will need to load from a file . The file describes the fields I need to map from the payload to another external api field. These fields do change often. What type of caching should I use
The caveat is there will be more fields that will be coming in future release until its production ready.
There will be API calls that invoke methods that will invoke these definitions from the cache
1) read file and store in memory [app server]
2) create static variables
2) should I use redis
3) should I use mongodb
if I do use a cache and this is static data . Do I need to use TTL ? or an eviction policy . I do not think so . But wanted to confirm if there was a use case
Even more important, what sort of system is this? A web application? A desktop app? A document manger? Source code repository? ???
Systems may have multiple caches and multiple levels of cache. Until we have some idea of the purpose of the system and its expected data flows, it's hard to say.
Also, MongoDB is a full-fledged NoSQL database and while you can cache using it - or IBM's SB/2 for that matter, it's note generally responsive enough to be in the same league as redis.
It is a good idea for have a cache with a purge policy unless your cache is at least as large as the set of items to be cached. I once discovered - the hard way - meaning days of tests - that the Oracle JDBC driver I was using had a bottomless cache. Well, the cache might have been bottomless, but the webapp/server threw OutOfMemory after about 2 and a half days of processing.
In fairness, this was officially documented behavior. I found the webpage that mentioned it in a locked washroom down in the basement with a filing cabinet in front of it and a sign on the door saying "Beware of the Leopard".
Science is the process of replacing what we "know" with what is TRUE. Politics, alas, often prefers to be the opposite.