reg2005 / adonis5-cache Goto Github PK
View Code? Open in Web Editor NEWSimple cache provider for AdonisJS 5
License: MIT License
Simple cache provider for AdonisJS 5
License: MIT License
Flushing with tags only causes the tag record to be removed. The actual records are not removed.
Before Flush | After Flush |
---|---|
The expiration time is not being set correctly.
If I add to the cache at 2024-02-14 00:16:47 and the record will expire in one hour, the expiration time in the tag is 2024-02-14 00:16:47, not 2024-02-14 01:16:47
{
"expirationTime": "2024-02-14T00:16:47.308Z",
"keys": [
"programmes:{\"filter\":{\"epgId\":\"abc.us\",\"startAt\":\"2024-02-14T00:00:00.000+00:00\"}}"
]
}
My cache config is this
import { CacheConfig } from '@ioc:Adonis/Addons/Adonis5-Cache';
export default {
recordTTL: 60, // record ttl in minutes,
ttlUnits: 'm', // time units for ttl record
currentCacheStorage: 'redis', // storages which used as default cache storage
enabledCacheStorages: ['in-memory', 'redis'], // storages which will be loaded
cacheKeyPrefix: 'cache_record_', // prefix for keys, which will be stored in cache storage
enabledEvents: {
'cache-record:read': false,
'cache-record:written': false,
'cache-record:missed': false,
'cache-record:forgotten': false,
},
} as CacheConfig;
This is getting the TTL as 60, instead of it being converted to ms, so it's only adding 60ms to the expiraton instead of 3600000ms.
adonis5-cache/src/TaggableCacheManager.ts
Lines 57 to 65 in cc28fd5
Changing this to
protected async saveTaggedKeys(keys: string[], ttl: number = this.cacheManager.recordTTL) {
const tagPayload = JSON.stringify({
expirationTime: dayjs().add(ttl, this.cacheManager.cacheConfig.ttlUnits).toISOString(),
keys,
})
await Promise.all(
this._tags.map((tag) => this.storage.addTag(this.buildTagKey(tag), tagPayload))
)
}
Fixes the issue.
1.3.1
v18.17.0
await Cache.tags('programmes').put(cacheKey, programmes);
await Cache.tags('programmes').flush()
Hey,
Could you please update the adonis redis version. The current one 7.0.2.
At the moment if someone uses the auth module this package can't be installed because of this issue.
The auth module needs the 7th version of redis, you need the 5th.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.