redis not setting expire time

AnonymousTRIAL

10 months ago

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

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 🙂

0 Replies

AnonymousTRIAL

10 months ago

367c8848-a813-4e35-a994-6367d8702c73


10 months ago

This would indicate an issue with the cache-manager package, 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


AnonymousTRIAL

10 months 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

thanks for your help 🤝


10 months ago

in the future please keep an open mind when someone says that it isn't a platform issue


10 months ago

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


redis not setting expire time - Railway Help Station