Moderator
Yui
(@fierevere)
永子
Usually you dont need that, redis-server does manage memory by itself.
If you have cache full all the times, perhaps you have to increase memory using directive
maxmemory
in redis-server config.
Clearing policy is handled by directive
maxmemory-policy
good choices for it are
maxmemory-policy volatile-ttl
or
maxmemory-policy volatile-lru
Можно посмотреть здесь https://docs.selectel.ru/managed-databases/redis/eviction-policy/
Для вашего хостинга beget стоит обратиться в техническую поддержку по поводу установки maxmemory-policy, т.к. похоже у них она не установлена https://dzen.ru/a/ZHngK89srk2BmtgK
https://dzen.ru/a/ZHngK89srk2BmtgK
-
This reply was modified 1 week, 6 days ago by
Yui.
But you didn’t just add the “clear cache” button for no reason, did you? I just want it to be done automatically.
you can call wp_cache_flush() using a WordPress schedule. If you’re running out of memory, you should get more memory.
function clear_my_cache_schedule() {
if ( function_exists( 'wp_cache_flush' ) ) {
wp_cache_flush();
}
}
function setup_cache_schedule() {
if ( ! wp_next_scheduled( 'daily_cache_flush' ) ) {
wp_schedule_event( time(), 'daily', 'daily_cache_flush' );
}
}
add_action( 'wp', 'setup_cache_schedule' );
add_action( 'daily_cache_flush', 'clear_my_cache_schedule' );
I won’t be increasing the memory. The hosting plans are high. I’ll use this code. Thank you.