문제

As far as Redis do not allow to reSet expire date to key (because of nans with replication) I'd like to know is there any method to check if key set to be expired or not?

Thank you

도움이 되었습니까?

해결책

Use the TTL command. If an expiration is set, it returns the number of seconds until the key expires; otherwise it returns -1.

다른 팁

I don't think checking for expiration date make much sense in Redis, though. I'd like to first suggest that you model it so you don't need to check for expiration date.

If you really need it, though, you can just use another key to store the expiration date for later retrieval via normal GET/SET.

Note that you can also check for EXPIRES manually in your client code, which might be a better solution.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top