【问题标题】:How to clear user cache in APCu?如何清除 APCu 中的用户缓存?
【发布时间】:2014-10-23 04:40:37
【问题描述】:

我已尝试使用此 PHP 代码清除用户缓存并从浏览器访问它:

<?php

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

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

但它不起作用。 (我正在使用这些工具来查看它是否有效https://rtcamp.com/tutorials/php/zend-opcache/

此外,当用户缓存已满时,它不会从 0 重新启动。APCu 只是停止工作。

我尝试设置apc.user_ttl=0,但 APCu 无法识别它。

我的设置是:

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

【问题讨论】:

    标签: caching apc php opcache


    【解决方案1】:
    <?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();
    }
    

    【讨论】:

      【解决方案2】:

      你用的工具是Opcache的,它不知道APCu。

      需要查看APCu状态的脚本是:

      如果您认为自己发现了错误,请在 github 上报告。

      【讨论】:

      • 链接无效,不值得发代码应该直接放这里
      猜你喜欢
      • 2018-06-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-25
      • 1970-01-01
      • 2017-02-26
      • 1970-01-01
      • 1970-01-01
      • 2015-01-28
      相关资源
      最近更新 更多