R
Railwayβ€’4w 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β€’4w ago
Project ID: 367c8848-a813-4e35-a994-6367d8702c73
massi
massiβ€’4w ago
367c8848-a813-4e35-a994-6367d8702c73
Brody
Brodyβ€’4w 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β€’4w 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β€’4w 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