R
Railwayβ€’6mo ago
massi

redis not setting expire time

hi, i have a redis instance in a project that is not setting the ttl when setting value in the cache here's an example of my code
await this.cache.set(phoneNumber, conversationState, 7200000); // 2 hours expiration
await this.cache.set(phoneNumber, conversationState, 7200000); // 2 hours expiration
i'm using nestjs with "@nestjs/cache-manager": "^2.2.2" to check i did: in railway's dashboard β†’ redis instance β†’ data, keys have "no expiry" and via redis-cli connecting to the instance deployed in railway. i also then tested by setting and expire second in the railway's dasboard and the checking if there was a TTL for that key via redis-cli and it had. then runned in my local env with a local redis instance, checked the keys via redis-cli, also TTL was correctly set i have the same configuration and code in other projects hosted in AWS and Render. there works perfect, here just don't, would be nice to have help for the Railway team πŸ™‚
Solution:
@Brody you were right, no idea exactly why this happens, but it's a problem with the cache-manager from v4 to v5 i solved it by doing ``` await this.cache.set(phoneNumber, conversationState, { ttl: 60 * 60 * 2 } as any); // 2 hours expiration...
Jump to solution
5 Replies
Percy
Percyβ€’6mo ago
Project ID: 367c8848-a813-4e35-a994-6367d8702c73
massi
massiOPβ€’6mo ago
367c8848-a813-4e35-a994-6367d8702c73
Brody
Brodyβ€’6mo ago
This would indicate an issue with the cache-manager package or how you have it setup, something like it being incompatible with the version of Redis that is deployed on Railway, Railway deploys a bog standard Redis database with nothing special going on so this wouldn't be an issue with Redis or the platform
Solution
massi
massiβ€’6mo ago
@Brody you were right, no idea exactly why this happens, but it's a problem with the cache-manager from v4 to v5 i solved it by doing
await this.cache.set(phoneNumber, conversationState, { ttl: 60 * 60 * 2 } as any); // 2 hours expiration
await this.cache.set(phoneNumber, conversationState, { ttl: 60 * 60 * 2 } as any); // 2 hours expiration
thanks for your help 🀝
Brody
Brodyβ€’6mo ago
in the future please keep an open mind when someone says that it isn't a platform issue also noticed you opened a private thread, please do not open private threads unless you need to share sensitive information with the team, it is not for personal development support
Want results from more Discord servers?
Add your server