Harris Adamovic
Harris Adamovic

Reputation: 87

how to compare unix timestamp in Redis?

Suppose i have a unix timestamp value that stored in a key

> SET timer 1465057009

Is there command to compare the timestamp with current timestamp?

> IS_BEFORE_NOW(timer)
1

Upvotes: 0

Views: 1122

Answers (1)

Karthikeyan Gopall
Karthikeyan Gopall

Reputation: 5689

No. But you can use a simple lua script to achieve it. For that you need to use redis command time which will return you the server's time.

local timer=redis.call("get","timer")
if timer > redis.call("time")[1] then
    return true
end
return false

Upvotes: 2

Related Questions