我正在使用Amazon Elastic Cache中的Redis。当我创建密钥时,它会在1到40秒的随机时间间隔内自动删除
**************:6379> set testkey 1
OK
**************:6379> get testkey
"1"
**************:6379> get testkey
"1"
**************:6379> get testkey
"1"
**************:6379> get testkey
(nil)
即使我设置了过期时间,它仍然不符合该时间
**************:6379> set testkey 1
OK
**************:6379> expire testkey 1000
(integer) 1
**************:6379> ttl testkey
(integer) 996
**************:6379> ttl testkey
(integer) 994
**************:6379> ttl testkey
(integer) -2
**************:6379> get testkey
(nil)
我尝试搜索文章,但找不到可靠的解决方案。请帮助我或为我指明正确的方向
我的信息全部输出
# Server
redis_version:4.0.10
redis_git_sha1:0
redis_git_dirty:0
redis_build_id:0
redis_mode:standalone
os:Amazon ElastiCache
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:0.0.0
process_id:1
run_id:9b47409883d74bd6226f6da83049f0299306942f
tcp_port:6379
uptime_in_seconds:1532242
uptime_in_days:17
hz:10
lru_clock:8988158
executable:-
config_file:-
# Clients
connected_clients:1584
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:41694472
used_memory_human:39.76M
used_memory_rss:45117440
used_memory_rss_human:43.03M
used_memory_peak:46522760
used_memory_peak_human:44.37M
used_memory_peak_perc:89.62%
used_memory_overhead:33041108
used_memory_startup:3662144
used_memory_dataset:8653364
used_memory_dataset_perc:22.75%
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:436469760
maxmemory_human:416.25M
maxmemory_policy:volatile-lru
mem_fragmentation_ratio:1.08
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0
# Persistence
loading:0
rdb_changes_since_last_save:54915489
rdb_bgsave_in_progress:0
rdb_last_save_time:1534182572
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
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
aof_last_cow_size:0
# Stats
total_connections_received:6594931
total_commands_processed:311024303
instantaneous_ops_per_sec:345
total_net_input_bytes:47103888444
total_net_output_bytes:1706056764081
instantaneous_input_kbps:20.91
instantaneous_output_kbps:2093.84
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:2573
expired_stale_perc:0.00
expired_time_cap_reached_count:0
evicted_keys:0
keyspace_hits:23866292
keyspace_misses:234233574
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
# Replication
role:master
connected_slaves:0
master_replid:ab5f0fbbecf06195be44983dbde289e2d0725335
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:8175.90
used_cpu_user:5509.23
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
# Commandstats
cmdstat_ping:calls=434117,usec=366264,usec_per_call=0.84
cmdstat_set:calls=6641,usec=23175,usec_per_call=3.49
cmdstat_config:calls=3,usec=55,usec_per_call=18.33
cmdstat_del:calls=20684265,usec=38010326,usec_per_call=1.84
cmdstat_keys:calls=1,usec=34,usec_per_call=34.00
cmdstat_exists:calls=458,usec=899,usec_per_call=1.96
cmdstat_expire:calls=4229654,usec=9412184,usec_per_call=2.23
cmdstat_flushdb:calls=27478,usec=14170960,usec_per_call=515.72
cmdstat_get:calls=248088801,usec=1086400958,usec_per_call=4.38
cmdstat_setex:calls=20257389,usec=63289845,usec_per_call=3.12
cmdstat_ttl:calls=2202549,usec=3262291,usec_per_call=1.48
cmdstat_getset:calls=7808523,usec=25766044,usec_per_call=3.30
cmdstat_select:calls=6594457,usec=6533380,usec_per_call=0.99
cmdstat_info:calls=689967,usec=219565932,usec_per_call=318.23
# SSL
ssl_enabled:no
ssl_connections_to_previous_certificate:0
ssl_connections_to_current_certificate:0
ssl_current_certificate_not_before_date:(null)
ssl_current_certificate_not_after_date:(null)
ssl_current_certificate_serial:0
# Cluster
cluster_enabled:0
# Keyspace
db0:keys=4604,expires=4604,avg_ttl=172095914
答案 0 :(得分:1)
我们使用的是laravel框架,由于某种原因,我们每分钟都要运行artisan clear:cache
,如@himanshu gupta所指出的那样。
我移除了cron,一切正常