导读:本文旨在介绍如何获取redis当前时间。首先,介绍了使用TIME命令来获取redis当前时间的方法;其次,介绍了如何使用INFO命令来查看redis服务器的当前时间;最后,总结了两种获取redis当前时间的方法。
1. 使用TIME命令来获取redis当前时间。TIME命令返回一个数组,其中包含两个元素:第一个元素是以秒为单位的UNIX时间戳,而第二个元素则是以毫微秒为单位的UNIX时间戳。可以使用以下命令来获取redis当前时间:
```
127.0.0.1:6379> TIME
1) "1592102046"
2) "681483"
```
2. 使用INFO命令来查看redis服务器的当前时间。INFO命令可以返回有关redis实例的详细信息,其中包括服务器的当前时间。可以使用以下命令来获取redis服务器的当前时间:
```
127.0.0.1:6379> INFO
# Server
redis_version:5.0.3
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:6a7d8e9f4f2e99c4
redis_mode:standalone
os:Linux 4.4.0-148-generic x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:5.4.0
process_id:1716
run_id:f3bfeefc53a75b7e66af8edac7b2a19a2f2faa3b
tcp_port:6379
uptime_in_seconds:37
uptime_in_days:0
hz:10
lru_clock:115925
config_file:/etc/redis/6379.conf
# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:152512
used_memory_human:149.08K
used_memory_rss:1890304
used_memory_rss_human:1.81M
used_memory_peak:152512
used_memory_peak_human:149.08K
total_system_memory:16771845120
total_system_memory_human:15.62G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:1.21
mem_allocator:jemalloc-5.2.1
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1592101138
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
# Stats
total_connections_received:1
total_commands_processed:3
instantaneous_ops_per_sec:0
total_net_input_bytes:30
total_net_output_bytes:177
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok