Why few keys in redis has no TTL?
Hey im noticing many keys are there in redis which has no TTL, so it stays forever, session information will be expiry after 30 days,
Im using secondary database as redis by passing
secondaryStorage: {
get: async (key) => {
const value = await redis.get(key);
return value ? value : null;
},
set: async (key, value, ttl) => {
if (ttl) await redis.set(key, value, ttl);
else await redis.set(key, value);
},
delete: async (key) => {
await redis.delete(key);
},
},
to auth
Just need to understand how to add ttl to this? and is it bug?
because of this redis is getting huge amout of data,
even when this is used? ๐

9 Replies
@admin please check this
Because I'm using secondary database to get rid of the load for primary database mongodb
@bekacru
looking into this
Thanks @bekacru
In code itself I checked a lot
Not getting from where these info pushing to secondary database
Please let me know if any additional information needed
Hey
https://github.com/better-auth/better-auth/issues/4034
I have added more information here, but ticket closed, ๐
GitHub
Why few keys in redis has no TTL? ยท Issue #4034 ยท better-auth/bet...
Is this suited for github? Yes, this is suited for github To Reproduce Hey im noticing many keys are there in redis which has no TTL, so it stays forever, session information will be expiry after 3...
Hey, I have debugged and found that it does not have a TTL
Here is a screenshot
while setting to Redis, a few don't have TTL,
Mainly, I can see that the keys are api endpoint names,
My Redis function to set is working fine,




I just re-opened it, sorry for the inconvenience.
Yes, i checked it today again, its happening for the apis of better-auth if i call any api it pushes one key value to redis,
which is not having any TTL,
for each user its pushing key value with their IP,
so redis is consuming lot of memory,
User's Session data is having TTL, crosschecked it.
Yeah, it's an active issue
I tried to look for this same issue on Github to see if there was a duplicate but couldn't find any, I suppose I've seen this issue before on Discord
I do think it's a big issue so I'll make sure it's a higher priority
Oh ok.. Carry On.
not a hurry, hope will fix this in future releases,
i though im using ratelimit thats why each api is storing there,
but im not using any ratelimit