Memcache::setCompressThreshold
(PECL memcache >= 2.0.0)
Memcache::setCompressThreshold — 开启大值自动压缩
说明
Memcache::setCompressThreshold() 开启对于大值的自动压缩。 同样你也可以使用函数 memcache_set_compress_threshold()。
注意:
此函数在 memcache 2.0.0 加入。
参数
threshold
-
控制多大值进行自动压缩的阈值。
min_saving
-
指定经过压缩实际存储的值的压缩率,支持的值必须在0和1之间。默认值是 0.2 表示 20% 压缩率。
示例
示例 #1 Memcache::setCompressThreshold() 示例
<?php
/* OO API */
$memcache_obj = new Memcache;
$memcache_obj->addServer('memcache_host', 11211);
$memcache_obj->setCompressThreshold(20000, 0.2);
/* procedural API */
$memcache_obj = memcache_connect('memcache_host', 11211);
memcache_set_compress_threshold($memcache_obj, 20000, 0.2);
?>
+添加备注
用户贡献的备注 1 note
spam at croler dot net ¶
11 years ago
The strangest thing is that you don't supply a server as parameter to setCompressThreshold(), so the value should be related to the memcache module, not the server itself. However it's required that you have added a server before you can set compress threshold. The documentation does not specify if the servers that are added after the call to this function will have the set value. I would test it and post, but since it's not documented the behavior could change.
So if you want to be sure -> set the threshold every time you add a server.
备份地址:http://www.lvesu.com/blog/php/memcache.setcompressthreshold.php