The time
command gives me a list, and I'm not able to get the first element in it using any normal list commands.
redis 127.0.0.1:6379> time
1) "1375802172"
2) "168215"
redis 127.0.0.1:6379> lrange time 0 1
(empty list or set)
The time
command gives me a list, and I'm not able to get the first element in it using any normal list commands.
redis 127.0.0.1:6379> time
1) "1375802172"
2) "168215"
redis 127.0.0.1:6379> lrange time 0 1
(empty list or set)
It is completely unrelated to a Redis list type. The fact that a number of list operations return a multi-bulk reply does not mean that all multi-bulk replies are Redis lists.
TIME does return a standard multi-bulk reply containing two values. The first one is the Unix epoch time, and the second the number of microseconds.
If you only need one of these values, it is up to the client program to select it.
SET
command in Redis documentation. It's pretty straightforward. I recommend you to go over one of the Redis tutorials out there. –
Puleo The previous answer is correct, TIME does not return a redis list.
However, you might be able to achieve what you are seeking using a lua script:
EVAL "return redis.call('TIME')[1]" 0 0
My suggestion to get the Unix epoch milliseconds in a Redis Lua script would be:
EVAL "local time = redis.call('TIME'); local now = math.floor(time[1] * 1000 + time[2] / 1000); return now" 0 blah
A quick demo using "redis-cli" and Linux "date" commands:
By the way, the timezone doesn't matter for the epoch seconds or milliseconds - because it is an amount of them passed since a certain event in the year 1970.
And that amount of time would be same regardless of your location on the planet Earth (unless you are travelling with near light speed).
© 2022 - 2024 — McMap. All rights reserved.