T
T
testopikachu2019-03-15 10:48:19
Redis
testopikachu, 2019-03-15 10:48:19

Why can laravel reset Cache::forever() in conjunction with redis?

Hello, I have laravel 5.7 and redis 3.2.12
Periodically, about once a day, the cache that was set forever is reset - Cache::forever('key', 'val');
I was able to google that when redis runs out of memory, it throws out the old records, but after installing the maxmemory 1000mbsituation has not changed. And there is not much information there, even 10mb should have been enough.
Tell me where to dig?
Here is the laravel config:

CACHE_DRIVER=redis
SESSION_DRIVER=redis
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

And here is the redis config, standard from centos 7, except for maxmemory 1000mb:
bind 127.0.0.1
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /var/log/redis/redis.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
maxmemory 1000mb
maxmemory-policy allkeys-lru
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gennady, 2019-03-15
@andaril

It is worth noting that the cache itself cannot serve as persistent storage. And forever() only says to remember the data for the maximum amount of time.
It is also worth looking at your application deployment script, perhaps it executes the \Cache::flush() command, which clears the entire cache. php artisan cache:reset - does the same thing.
In the configs there is such a line here , which will allow you to limit the scope of the cache reset to "your" database.
And to try to get at least some storage persistence - use \Redis
ps: it's rather difficult to answer in more detail, because it is not known what is happening in your application. Maybe your code overwrites the data itself due to a logical error and you put your own key \Cache::forever('key', null);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question