• Resolved calliko

    (@calliko)


    Hello. I have a question about the topic. My hosting service keeps warning me that my memory is full. I have to manually clear the cache in the plugin. Is there a way to clear it automatically, for example, once every 24 hours?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.
    Thread Starter calliko

    (@calliko)

    But you didn’t just add the “clear cache” button for no reason, did you? I just want it to be done automatically.

    Plugin Author Till Krüss

    (@tillkruess)

    you can call wp_cache_flush() using a WordPress schedule. If you’re running out of memory, you should get more memory.

    Thread Starter calliko

    (@calliko)

    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.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.