Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear user cache in APCu?

I have tried to clear the user cache using this PHP code and access it from the browser:

<?php

apc_clear_cache();
apc_clear_cache('user');
apc_clear_cache('opcode');

echo json_encode(array(
    'success' => true,
));

but it doesn't work. (I am using these tools to see if it's working or not https://rtcamp.com/tutorials/php/zend-opcache/ )

Also when the user cache gets full, it doesn't restart from 0. The APCu just stops working.

I have tried to set apc.user_ttl=0, but APCu doesn't recognize it.

My settings are:

extension=apcu.so
apc.enabled=1
apc.shm_size=10240M
apc.ttl=7200
apc.enable_cli=1
apc.gc_ttl=3600
apc.entries_hint=4096
apc.slam_defense=0
apc.enable_cli = 1
apc.user_ttl=0
apc.serializer=igbinary
like image 364
Keloglan Avatar asked Dec 12 '22 03:12

Keloglan


1 Answers

<?php

if (extension_loaded('apc')) {
    echo "APC-User cache: " . apc_clear_cache('user') . "\n";
    echo "APC-System cache: " . apc_clear_cache() . "\n";
}

if (extension_loaded('apcu')) {
    echo "APCu cache: " . apcu_clear_cache() . "\n";
}

if (function_exists('opcache_reset')) {
    // Clear it twice to avoid some internal issues...
    opcache_reset();
    opcache_reset();
}
like image 107
Aistis Avatar answered Dec 22 '22 16:12

Aistis