[Human App] fix: cache-manager ttl usage #2742
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixing invalid usage of cache-manager
ttl
value.Summary of changes
We use
@nestjs/[email protected]
that under the hood just creates instance ofcache-manager
package (ref) that is being installed in the project (5.4.0 in our case). When we importCache
type for it - we see thatttl
is just a third argument and is in milliseconds. Under the hoodcache-manager
calls theset
method of the store (ref) in the same fashion. However, when we register cache module, we create a redis store based oncache-manager-redis-store
, that accepts ttl inoptions
argument (ref), so it's not compatible with the used version ofcache-manager
, so in order to fix that we have two options:cache-manager
to v4, that used same signature (ref)cache-manager-redis-yet
that is compatible with v5 (ref)I decided to go with the second option due to next reasons:
nestjs
docs, so it's not surprisingcache-manager-redis-yet
is deprecated, it can be removed from npm due to dependencies and number of downloads; and at the same timenestjs/cache-manager
should introduce support for thecache-manager/v6
soone that should eliminate such dep (ref); once it's there - we will upgrade and also get back to using secondsAlso refactored healthcheck for
cache-manager
: under the hood it can be any storage (Redis, Memcached, Mongo, etc.) and in case if health indicator depends on store's API we can miss updating our healthcheck if we change the storeHow test the changes
TTL
command to check that values are set on all necessary keysRelated issues
To close #2671, #2672