CakeFest 2024: The Official CakePHP Conference

Memcache::setCompressThreshold

(PECL memcache >= 2.0.0)

Memcache::setCompressThreshold大きな値に対する自動圧縮処理を有効にする

説明

Memcache::setCompressThreshold(int $threshold, float $min_savings = ?): bool

Memcache::setCompressThreshold() は、 大きな値に対して自動圧縮処理を有効にします。 memcache_set_compress_threshold() 関数を使用することも可能です。

注意:

この関数は、Memcache バージョン 2.0.0 で追加されました。

パラメータ

threshold

自動圧縮を試みる値の長さの最小値を指定します。

min_saving

値を圧縮する際の、最小の圧縮率を指定します。 値は 0 から 1 までの間で指定する必要があります。 デフォルト値は 0.2 で、最低 20% の圧縮を指定します。

戻り値

成功した場合に true を、失敗した場合に false を返します。

例1 Memcache::setCompressThreshold() の例

<?php

/* オブジェクト指向の API */

$memcache_obj = new Memcache;
$memcache_obj->addServer('memcache_host', 11211);
$memcache_obj->setCompressThreshold(20000, 0.2);

/* 手続き型の API */

$memcache_obj = memcache_connect('memcache_host', 11211);
memcache_set_compress_threshold($memcache_obj, 20000, 0.2);

?>

add a note

User Contributed Notes 1 note

up
2
spam at croler dot net
10 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.
To Top