【发布时间】:2019-01-02 16:01:57
【问题描述】:
我在 apache/php windows 10 上有 memcache 扩展(详情在最后)
创建了一个简单的测试:
$memcache = new Memcache;
$memcache->addServer("ext-memcached.e-memcached.xxx.net",11211);
$memcache->addServer("ext-memcached.e-memcached2.xxx.net",11211);
$memcache->addServer("ext-memcached.e-memcached3.xxx.net",11211);
$key='xxx_54921';
$settings = $memcache->get($key);
print_r ($settings);
memcache 服务器位于 AWS 上,它们运行良好(生产服务器)。 此测试代码有效 - 它从内存缓存服务器检索值。 但是,如果我等待几分钟并刷新它不会返回值。 然后,如果我再次刷新,它将返回该值。
相同的代码/配置在另一台开发计算机上工作。
这是什么原因造成的?
Config:
PHP Version 5.6.34
Windows NT SPECTRE 6.2 build 9200 (Windows 8 Home Premium Edition) i586
Build Date Feb 28 2018 17:45:55
Compiler MSVC11 (Visual C++ 2012)
Architecture x86
Memcache extension:
ts x86 version from here:
https://windows.php.net/downloads/pecl/releases/memcache/3.0.8/
memcache info:
memcache support enabled
Version 3.0.8
Revision $Revision: 329835 $
Directive Local Value Master Value
memcache.allow_failover 1 1
memcache.chunk_size 32768 32768
memcache.compress_threshold 20000 20000
memcache.default_port 11211 11211
memcache.hash_function crc32 crc32
memcache.hash_strategy standard standard
memcache.lock_timeout 600 600
memcache.max_failover_attempts 20 20
memcache.protocol ascii ascii
memcache.redundancy 1 1
memcache.session_redundancy 2 2
【问题讨论】:
-
与您的其他开发计算机有什么不同吗? php 版本、memcache 信息、memcache 版本、...?
-
你能试试 $stats = $memcache->getExtendedStats(); print_r($stats);添加服务器后?你也可以放置一个“sleep(2);”就在 $memcache->get 之前,当您尝试获取密钥并导致缓存未命中时,可能是 Memcache 库中服务器的“内部计数”尚未更新。
标签: php apache xampp php-extension libmemcache