In order to speed up the getting of Dataset Version Differences/Summary a cache will be used.
Also see #11503 for information regarding this ask.
Currently we have a CacheManager that handles the rate limiting data. This manager can be extended to cache json responses and store them in the Postgres database.
Some steps that need to be accomplished are:
- create a table in the database to hold the json responses.
CREATE IF NOT EXISTS UNLOGGED TABLE cache (
id SERIAL PRIMARY KEY,
key TEXT UNIQUE NOT NULL,
value JSONB,
created_at_utc TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
CREATE IF NOT EXISTS INDEX idx_cache_key ON cache (key);
- Modify the CacheFactoryBean to include the json response cache (in memory as well as persisted in Postgres)
- Define the key used to lookup the cache. User permission will determine what data is included in the response but the individual user id is not to be part of the key. The key needs to be limited so any user making this request will see the response that that would otherwise match the response based on their permissions.
- Create feature flag or setting to enable/disable cache. Allow for future caching by having one setting that defines various caches (similar to the rate limiting setting). Could include cache size, TTL, enable/disable.
- Invalidate the cache. Any update to the Dataset would need to invalid the cache.
- Evict from the cache. To keep the size of the cache "small" any data in the cache (db) that hasn't been accessed in a configurable amount of time should be deleted. In memory cache would be wiped out when the app restarts but also could be configured to be "trimmed" at a time interval or cache size limit.
- Cache retrieval. Goes without saying, if cached in memory return it, if not, check db and if found return that. If not in memory or in db perform the actual code to generate the json and if caching enabled save json to memory and db.
The current need is for Dataset Version Differences/Summary which can take a significant amount of time to generate.
In order to speed up the getting of Dataset Version Differences/Summary a cache will be used.
Also see #11503 for information regarding this ask.
Currently we have a CacheManager that handles the rate limiting data. This manager can be extended to cache json responses and store them in the Postgres database.
Some steps that need to be accomplished are:
CREATE IF NOT EXISTS UNLOGGED TABLE cache (
id SERIAL PRIMARY KEY,
key TEXT UNIQUE NOT NULL,
value JSONB,
created_at_utc TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
CREATE IF NOT EXISTS INDEX idx_cache_key ON cache (key);
The current need is for Dataset Version Differences/Summary which can take a significant amount of time to generate.