Memcache::setCompressThreshold
(PECL memcache >= 2.0.0)
Memcache::setCompressThreshold — Enable automatic compression of large values
Description
$threshold
[, float $min_savings
] )Memcache::setCompressThreshold() enables automatic compression of large values. You can also use the memcache_set_compress_threshold() function.
Note:
This function has been added to Memcache version 2.0.0.
Parameters
-
threshold
-
Controls the minimum value length before attempting to compress automatically.
-
min_saving
-
Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings.
Return Values
Returns TRUE
on success or FALSE
on failure.
Examples
Example #1 Memcache::setCompressThreshold() example
<?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);
?>
- Функция Memcache::add() - Add an item to the server
- Функция Memcache::addServer() - Add a memcached server to connection pool
- Функция Memcache::close() - Close memcached server connection
- Функция Memcache::connect() - Open memcached server connection
- Функция Memcache::decrement() - Decrement item's value
- Функция Memcache::delete() - Delete item from the server
- Функция Memcache::flush() - Flush all existing items at the server
- Функция Memcache::get() - Retrieve item from the server
- Функция Memcache::getExtendedStats() - Get statistics from all servers in pool
- Функция Memcache::getServerStatus() - Returns server status
- Функция Memcache::getStats() - Get statistics of the server
- Функция Memcache::getVersion() - Return version of the server
- Функция Memcache::increment() - Increment item's value
- Функция Memcache::pconnect() - Open memcached server persistent connection
- Функция Memcache::replace() - Replace value of the existing item
- Функция Memcache::set() - Store data at the server
- Функция Memcache::setCompressThreshold() - Enable automatic compression of large values
- Функция Memcache::setServerParams() - Changes server parameters and status at runtime
Коментарии
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.