Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis entries are not deleted #36

Open
aks-zero opened this issue Apr 27, 2020 · 5 comments
Open

redis entries are not deleted #36

aks-zero opened this issue Apr 27, 2020 · 5 comments

Comments

@aks-zero
Copy link

aks-zero commented Apr 27, 2020

Hi,
I use this application with Freeswitch. Entries created in the redis server are not deleted and stay forever even after the SIPREC call is terminated with BYE gracefully. It seems it's happening all the time. Will appreciate any help for this.
Thanks in advance.

@davehorton
Copy link
Collaborator

The redis keys are inserted with an expiry of 10 seconds, here

Therefore, they should disappear after 10 seconds. Perhaps the latter set request is somehow eliminating this expires value. Not sure, I will have to look into it

@davehorton
Copy link
Collaborator

could you do a test for me?

Try changing this line

from

.set(sessionId, sdp)

to

.set(sessionId, sdp, 'KEEPTTL')

and see if that fixes it?

@aks-zero
Copy link
Author

aks-zero commented Apr 27, 2020

You are right. I never see any TTL on the key as if it wasn't never set (it always returns -1). As you mentioned, I think the latter SET request is discarding the expiry value. From the Redis documetation:

Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation.

Since the KEEPTTL is supported only in Redis >= 6.0, I couldn't test. Will try after upgrading Redis.

Alternatively, may be we can set the the expiry again during the second call using 'SET EX' option or 'SETEX' command.

@davehorton
Copy link
Collaborator

yes, you could just replicate the set ex command as used earlier. Try that -- if it works let me know. Feel free to make a PR

@aks-zero
Copy link
Author

aks-zero commented Apr 28, 2020

Yes, that worked. Thanks a lot.

127.0.0.1:6379> KEYS *
1) "2fb147ed-549f-4ecf-aae0-0f9444cf9bb0"
127.0.0.1:6379> 
127.0.0.1:6379> ttl 2fb147ed-549f-4ecf-aae0-0f9444cf9bb0
(integer) 3
127.0.0.1:6379> 
127.0.0.1:6379> ttl 2fb147ed-549f-4ecf-aae0-0f9444cf9bb0
(integer) 0
127.0.0.1:6379> 
127.0.0.1:6379> ttl 2fb147ed-549f-4ecf-aae0-0f9444cf9bb0
(integer) -2
127.0.0.1:6379> 
127.0.0.1:6379> KEYS *
(empty list or set)
127.0.0.1:6379> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants