PECL extension is not bundled with PHP. Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions.) // ============================== USING FUNCTIONS (1) // memcache_debug() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== USING CLASSES (1) // PHP_OTHER_MEMCACHE_MEMCACHE - PECL_memcache_2_1_0 // ============================== USING DATA_TYPES (9) // bool // Memcache - PECL_memcache >= PECL_memcache_0_2_0 // string // mixed // int // callable // false // array // float // ============================== END // REQUIREMENTS // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE // ============================== ABOUT // PHP Manual / Function Reference / Other Services / Memcache // URL: https://www.php.net/manual/en/book.memcache.php // ============================== DESCRIPTION // MEMCACHE // // MEMCACHE - BEGIN // Memcache // // INTRODUCTION // INSTALLING_CONFIGURING // PREDEFINED_CONSTANTS // EXAMPLES // THE_MEMCACHE_CLASS // MEMCACHE_FUNCTIONS // // INTRODUCTION - BEGIN // Introduction // // Memcache module provides handy procedural and object-oriented interface to memcached, highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications. // The Memcache module also provides a session handler (memcache). // More information about memcached can be found at > http://www.memcached.org/. // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/intro.memcache.php // INTRODUCTION - END // // INSTALLING_CONFIGURING - BEGIN // Installing/Configuring // // REQUIREMENTS // INSTALLATION // RUNTIME_CONFIGURATION // RESOURCE_TYPES // // REQUIREMENTS - BEGIN // Requirements // // This module uses functions of > zlib to support on-the-fly data compression. Zlib is required to install this module. // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/memcache.requirements.php // REQUIREMENTS - END // // INSTALLATION - BEGIN // Installation // // This > PECL extension is not bundled with PHP. Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: > https://pecl.php.net/package/memcache. // Note: It's possible to disable memcache session handler support. The 'pecl install' option prompts for this (default is enabled) however when compiling statically into PHP the --disable-memcache-session configure option may be used. // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/memcache.installation.php // INSTALLATION - END // // RUNTIME_CONFIGURATION - BEGIN // Runtime Configuration // // The behaviour of these functions is affected by settings in php.ini. // // Memcache Configuration Options // Name | Default | Changeable | Changelog // memcache.allow_failover | "1" | PHP_INI_ALL | Available since memcache 2.0.2. // memcache.max_failover_attempts | "20" | PHP_INI_ALL | Available since memcache 2.1.0. // memcache.chunk_size | "8192" | PHP_INI_ALL | Available since memcache 2.0.2. // memcache.default_port | "11211" | PHP_INI_ALL | Available since memcache 2.0.2. // memcache.hash_strategy | "standard" | PHP_INI_ALL | Available since memcache 2.2.0. // memcache.hash_function | "crc32" | PHP_INI_ALL | Available since memcache 2.2.0. // memcache.protocol | ascii | >PHP_INI_ALL | Supported since memcache 3.0.0 // memcache.redundancy | 1 | >PHP_INI_ALL | Supported since memcache 3.0.0 // memcache.session_redundancy | 2 | >PHP_INI_ALL | Supported since memcache 3.0.0 // memcache.compress_threshold | 20000 | >PHP_INI_ALL | Supported since memcache 3.0.3 // memcache.lock_timeout | 15 | >PHP_INI_ALL | Supported since memcache 3.0.4 // // Session Configuration Options Affecting Memcache Behavior // Name | Default | Changeable | Changelog // session.save_handler | "files" | PHP_INI_ALL | Supported since memcache 2.1.2 // session.save_path | "" | PHP_INI_ALL | Supported since memcache 2.1.2 // // For further details and definitions of the PHP_INI_* modes, see the Where a configuration setting may be set. // Here's a short explanation of the configuration directives. // // memcache.allow_failover bool - Whether to transparently failover to other servers on errors. // memcache.max_failover_attempts int - Defines how many servers to try when setting and getting data. Used only in conjunction with memcache.allow_failover. // memcache.chunk_size int - Data will be transferred in chunks of this size, setting the value lower requires more network writes. Try increasing this value to 32768 if noticing otherwise inexplicable slowdowns. // memcache.default_port string - The default TCP port number to use when connecting to the memcached server if no other port is specified. // memcache.hash_strategy string - Controls which strategy to use when mapping keys to servers. Set this value to consistent to enable consistent hashing which allows servers to be added or removed from the pool without causing keys to be remapped. Setting this value to standard results in the old strategy being used. // memcache.hash_function string - Controls which hash function to apply when mapping keys to servers, crc32 uses the standard CRC32 hash while fnv uses FNV-1a. // memcache.protocol string - // memcache.redundancy int - // memcache.session_redundancy int - // memcache.compress_threshold int - // memcache.lock_timeout int - // session.save_handler string - Use memcache as a session handler by setting this value to memcache. // session.save_path string - Defines a comma separated of server urls to use for session storage, for example "tcp://host1:11211, tcp://host2:11211". // Each url may contain parameters which are applied to that server, they are the same as for the Memcache::addServer() method. For example "tcp://host1:11211?persistent=1&weight=1&timeout=1&retry_interval=15" // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/memcache.ini.php // RUNTIME_CONFIGURATION - END // // RESOURCE_TYPES - BEGIN // Resource Types // // There is only one resource type used in memcache module - it's the link identifier for a cache server connection. // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/memcache.resources.php // RESOURCE_TYPES - END // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/memcache.setup.php // INSTALLING_CONFIGURING - END // // PREDEFINED_CONSTANTS - BEGIN // Predefined Constants // // Memcache Constants // Name - Description // MEMCACHE_COMPRESSED (int) - Used to turn on-the-fly data compression on with Memcache::set(), Memcache::add() and Memcache::replace(). // MEMCACHE_HAVE_SESSION (int) - 1 if this Memcache session handler is available, 0 otherwise. // MEMCACHE_USER1 (int) - Used to turn user-defined application flag on with Memcache::set(), Memcache::add() and Memcache::replace(). // MEMCACHE_USER2 (int) - Used to turn user-defined application flag on with Memcache::set(), Memcache::add() and Memcache::replace(). // MEMCACHE_USER3 (int) - Used to turn user-defined application flag on with Memcache::set(), Memcache::add() and Memcache::replace(). // MEMCACHE_USER4 (int) - Used to turn user-defined application flag on with Memcache::set(), Memcache::add() and Memcache::replace(). // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/memcache.constants.php // PREDEFINED_CONSTANTS - END // // EXAMPLES - BEGIN // Examples // // BASIC_USAGE // // BASIC_USAGE - BEGIN // Basic usage // // [example] // Example #1 memcache extension overview example // In this example, an object is being saved in the cache and then retrieved back. Object and other non-scalar types are serialized before saving, so it's impossible to store resources (i.e. connection identifiers and others) in the cache. // [php] // // $memcache = new Memcache; // $memcache->connect('localhost', 11211) or die ("Could not connect"); // // $version = $memcache->getVersion(); // echo "Server's version: ".$version."
\n"; // // $tmp_object = new stdClass; // $tmp_object->str_attr = 'test'; // $tmp_object->int_attr = 123; // // $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server"); // echo "Store data in the cache (data will expire in 10 seconds)
\n"; // // $get_result = $memcache->get('key'); // echo "Data from the cache:
\n"; // // var_dump($get_result); // // [/php] // [/example] // [example] // Example #2 Using memcache session handler // [php] // // $session_save_path = "tcp://$host:$port?persistent=1&weight=2&timeout=2&retry_interval=10, ,tcp://$host:$port "; // ini_set('session.save_handler', 'memcache'); // ini_set('session.save_path', $session_save_path); // // [/php] // [/example] // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/memcache.examples-overview.php // BASIC_USAGE - END // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/memcache.examples.php // EXAMPLES - END // // THE_MEMCACHE_CLASS - BEGIN // The Memcache class // // PECL_memcache >= PECL_memcache_0_2_0 // // Introduction // Represents a connection to a set of memcache servers. // // Class synopsis // [code] // class Memcache { // add( // string $key, // mixed $var, // int $flag = ?, // int $expire = ? // ): bool // addServer( // string $host, // int $port = 11211, // bool $persistent = ?, // int $weight = ?, // int $timeout = ?, // int $retry_interval = ?, // bool $status = ?, // callable $failure_callback = ?, // int $timeoutms = ? // ): bool // close(): bool // connect(string $host, int $port = ?, int $timeout = ?): bool // decrement(string $key, int $value = 1): int|false // delete(string $key, int $timeout = 0): bool // flush(): bool // get(string $key, int &$flags = ?): string // getExtendedStats(string $type = ?, int $slabid = ?, int $limit = 100): array // getServerStatus(string $host, int $port = 11211): int // getStats(string $type = ?, int $slabid = ?, int $limit = 100): array|false // getVersion(): string|false // increment(string $key, int $value = 1): int|false // pconnect(string $host, int $port = ?, int $timeout = ?): mixed // replace( // string $key, // mixed $var, // int $flag = ?, // int $expire = ? // ): bool // set( // string $key, // mixed $var, // int $flag = ?, // int $expire = ? // ): bool // setCompressThreshold(int $threshold, float $min_savings = ?): bool // setServerParams( // string $host, // int $port = 11211, // int $timeout = ?, // int $retry_interval = false, // bool $status = ?, // callable $failure_callback = ? // ): bool // } // [/code] // // Table of Contents // * 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 // // LITERATURE_SOURCES // * PHP_NET (2023-11-11) // URL: https://www.php.net/manual/en/class.memcache.php // THE_MEMCACHE_CLASS - END // // MEMCACHE_FUNCTIONS - BEGIN // Memcache Functions // // Table of Contents // * memcache_debug - Turn debug output on/off // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/ref.memcache.php // MEMCACHE_FUNCTIONS - END // // LITERATURE_SOURCES // * PHP_NET (2023-09-29) // URL: https://www.php.net/manual/en/book.memcache.php // MEMCACHE - END // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_DEBUG // ============================== PUBLIC // ============================== ABOUT // Turn debug output on/off. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING FUNCTIONS (1) // memcache_debug() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_debug($on_off) { $return_memcache_debug = false; // ========== MEMCACHE_DEBUG - BEGIN // ===== ABOUT // Turn debug output on/off // ===== DESCRIPTION // memcache_debug() turns on debug output if parameter on_off is equal to true and turns off if it's false. // Note: memcache_debug() is accessible only if PHP was built with --enable-debug option and always returns true in this case. Otherwise, this function has no effect and always returns false. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_2_0 // ===== SYNTAX // memcache_debug(bool $on_off): bool // ===== CODE $return_memcache_debug = memcache_debug( $on_off // bool on_off - Turns debug output on if equals to true. Turns debug output off if equals to false. ); // Return Values // Returns true if PHP was built with --enable-debug option, otherwise returns false. // ===== LITERATURE_SOURCES // * PHP_NET (2023-09-22) // URL: https://www.php.net/manual/en/function.memcache-debug.php // ========== MEMCACHE_DEBUG - END // SYNTAX: // bool memcache_debug(bool $on_off) return $return_memcache_debug; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_DEBUG // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE // ============================== PUBLIC // PHP_OTHER_MEMCACHE_MEMCACHE_ADD - bool php_other_memcache_memcache_add(Memcache $memcache, string $key, mixed $var, int $flag, int $expire) // PHP_OTHER_MEMCACHE_MEMCACHE_ADDSERVER - bool php_other_memcache_memcache_addserver(Memcache $memcache, string $host, int $port, bool $persistent, int $weight, int $timeout, int $retry_interval, bool $status, callable $failure_callback, int $timeoutms) // PHP_OTHER_MEMCACHE_MEMCACHE_CLOSE - bool php_other_memcache_memcache_close(Memcache $memcache) // PHP_OTHER_MEMCACHE_MEMCACHE_CONNECT - bool php_other_memcache_memcache_connect(Memcache $memcache, string $host, int $port, int $timeout) // PHP_OTHER_MEMCACHE_MEMCACHE_DECREMENT - int|false php_other_memcache_memcache_decrement(Memcache $memcache, string $key, int $value = 1) // PHP_OTHER_MEMCACHE_MEMCACHE_DELETE - bool php_other_memcache_memcache_delete(Memcache $memcache, string $key, int $timeout = 0) // PHP_OTHER_MEMCACHE_MEMCACHE_FLUSH - bool php_other_memcache_memcache_flush(Memcache $memcache) // PHP_OTHER_MEMCACHE_MEMCACHE_GET - string php_other_memcache_memcache_get(Memcache $memcache, string $key, int& $flags) // PHP_OTHER_MEMCACHE_MEMCACHE_GETEXTENDEDSTATS - array php_other_memcache_memcache_getextendedstats(Memcache $memcache, string $type, int $slabid, int $limit = 100) // PHP_OTHER_MEMCACHE_MEMCACHE_GETSERVERSTATUS - int php_other_memcache_memcache_getserverstatus(Memcache $memcache, string $host, int $port = 11211) // PHP_OTHER_MEMCACHE_MEMCACHE_GETSTATS - array|false php_other_memcache_memcache_getstats(Memcache $memcache, string $type, int $slabid, int $limit = 100) // PHP_OTHER_MEMCACHE_MEMCACHE_GETVERSION - string|false php_other_memcache_memcache_getversion(Memcache $memcache) // PHP_OTHER_MEMCACHE_MEMCACHE_INCREMENT - int|false php_other_memcache_memcache_increment(Memcache $memcache, string $key, int $value = 1) // PHP_OTHER_MEMCACHE_MEMCACHE_PCONNECT - mixed php_other_memcache_memcache_pconnect(Memcache $memcache, string $host, int $port, int $timeout) // PHP_OTHER_MEMCACHE_MEMCACHE_REPLACE - bool php_other_memcache_memcache_replace(Memcache $memcache, string $key, mixed $var, int $flag, int $expire) // PHP_OTHER_MEMCACHE_MEMCACHE_SET - bool php_other_memcache_memcache_set(Memcache $memcache, string $key, mixed $var, int $flag, int $expire) // PHP_OTHER_MEMCACHE_MEMCACHE_SETCOMPRESSTHRESHOLD - bool php_other_memcache_memcache_setcompressthreshold(Memcache $memcache, int $threshold, float $min_saving) // PHP_OTHER_MEMCACHE_MEMCACHE_SETSERVERPARAMS - bool php_other_memcache_memcache_setserverparams(Memcache $memcache, string $host, int $port, int $timeout, int $retry_interval, bool $status, callable $failure_callback) // ============================== SUPPORT // PECL_memcache_2_1_0 // ============================== USING SUBCLASSES (18) // Memcache::add() - PECL_memcache >= PECL_memcache_0_2_0 // Memcache::addServer() - PECL_memcache >= PECL_memcache_2_0_0 // Memcache::close() - PECL_memcache >= PECL_memcache_0_4_0 // Memcache::connect() - PECL_memcache >= PECL_memcache_0_2_0 // Memcache::decrement() - PECL_memcache >= PECL_memcache_0_2_0 // Memcache::delete() - PECL_memcache >= PECL_memcache_0_2_0 // Memcache::flush() - PECL_memcache >= PECL_memcache_1_0_0 // Memcache::get() - PECL_memcache >= PECL_memcache_0_2_0 // Memcache::getExtendedStats() - PECL_memcache >= PECL_memcache_2_0_0 // Memcache::getServerStatus() - PECL_memcache >= PECL_memcache_2_1_0 // Memcache::getStats() - PECL_memcache >= PECL_memcache_0_2_0 // Memcache::getVersion() - PECL_memcache >= PECL_memcache_0_2_0 // Memcache::increment() - PECL_memcache >= PECL_memcache_0_2_0 // Memcache::pconnect() - PECL_memcache >= PECL_memcache_0_4_0 // Memcache::replace() - PECL_memcache >= PECL_memcache_0_2_0 // Memcache::set() - PECL_memcache >= PECL_memcache_0_2_0 // Memcache::setCompressThreshold() - PECL_memcache >= PECL_memcache_2_0_0 // Memcache::setServerParams() - PECL_memcache >= PECL_memcache_2_1_0 // ============================== USING DATA_TYPES (9) // bool // Memcache - PECL_memcache >= PECL_memcache_0_2_0 // string // mixed // int // callable // false // array // float // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_ADD // ============================== PUBLIC // ============================== ABOUT // Add an item to the server. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING SUBCLASSES (1) // Memcache::add() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_add($memcache, $key, $var, $flag, $expire) { $return_memcache_add = false; // ========== MEMCACHE_ADD - BEGIN // ===== ABOUT // Add an item to the server // ===== DESCRIPTION // Memcache::add() stores variable var with key only if such key doesn't exist at the server yet. Also you can use memcache_add() function. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_2_0 // ===== SYNTAX // Memcache::add( // string $key, // mixed $var, // int $flag = ?, // int $expire = ? // ): bool // ===== CODE $return_memcache_add = $memcache->add( $key, // string key - The key that will be associated with the item. $var, // mixed var - The variable to store. Strings and integers are stored as is, other types are stored serialized. $flag, // int flag - Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib). $expire // int expire - Expiration time of the item. If it's equal to zero, the item will never expire. You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days). ); // Return Values // Returns true on success or false on failure. Returns false if such key already exist. For the rest Memcache::add() behaves similarly to Memcache::set(). // // [examples] // Examples // [example] // Example #1 Memcache::add() example // [php] // // $memcache_obj = memcache_connect("localhost", 11211); // // // procedural API // memcache_add($memcache_obj, 'var_key', 'test variable', false, 30); // // // OO API // $memcache_obj->add('var_key', 'test variable', false, 30); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-09) // URL: https://www.php.net/manual/en/memcache.add.php // ========== MEMCACHE_ADD - END // SYNTAX: // bool Memcache::add(string $key, mixed $var, int $flag, int $expire) return $return_memcache_add; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_ADD // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_ADDSERVER // ============================== PUBLIC // ============================== ABOUT // Add a memcached server to connection pool. // ============================== SUPPORT // PECL_memcache_2_0_0 // ============================== USING SUBCLASSES (1) // Memcache::addServer() - PECL_memcache >= PECL_memcache_2_0_0 // ============================== CODE function php_other_memcache_memcache_addserver($memcache, $host, $port, $persistent, $weight, $timeout, $retry_interval, $status, $failure_callback, $timeoutms) { $return_memcache_addserver = false; // ========== MEMCACHE_ADDSERVER - BEGIN // ===== ABOUT // Add a memcached server to connection pool // ===== DESCRIPTION // Memcache::addServer() adds a server to the connection pool. You can also use the memcache_add_server() function. // When using this method (as opposed to Memcache::connect() and Memcache::pconnect()) the network connection is not established until actually needed. Thus there is no overhead in adding a large number of servers to the pool, even though they might not all be used. // Failover may occur at any stage in any of the methods, as long as other servers are available the request the user won't notice. Any kind of socket or Memcached server level errors (except out-of-memory) may trigger the failover. Normal client errors such as adding an existing key will not trigger a failover. // Note: This function has been added to Memcache version 2.0.0. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_2_0_0 // ===== SYNTAX // Memcache::addServer( // string $host, // int $port = 11211, // bool $persistent = ?, // int $weight = ?, // int $timeout = ?, // int $retry_interval = ?, // bool $status = ?, // callable $failure_callback = ?, // int $timeoutms = ? // ): bool // ===== CODE $return_memcache_addserver = $memcache->addServer( $host, // string host - Point to the host where memcached is listening for connections. This parameter may also specify other transports like unix:///path/to/memcached.sock to use UNIX domain sockets, in this case port must also be set to 0. $port, // int port - Point to the port where memcached is listening for connections. Set this parameter to 0 when using UNIX domain sockets. // Please note: port defaults to memcache.default_port if not specified. For this reason it is wise to specify the port explicitly in this method call. $persistent, // bool persistent - Controls the use of a persistent connection. Default to true. $weight, // int weight - Number of buckets to create for this server which in turn control its probability of it being selected. The probability is relative to the total weight of all servers. $timeout, // int timeout - Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow. $retry_interval, // int retry_interval - Controls how often a failed server will be retried, the default value is 15 seconds. Setting this parameter to -1 disables automatic retry. Neither this nor the persistent parameter has any effect when the extension is loaded dynamically via dl(). // Each failed connection struct has its own timeout and before it has expired the struct will be skipped when selecting backends to serve a request. Once expired the connection will be successfully reconnected or marked as failed for another retry_interval seconds. The typical effect is that each web server child will retry the connection about every retry_interval seconds when serving a page. $status, // bool status - Controls if the server should be flagged as online. Setting this parameter to false and retry_interval to -1 allows a failed server to be kept in the pool so as not to affect the key distribution algorithm. Requests for this server will then failover or fail immediately depending on the memcache.allow_failover setting. Default to true, meaning the server should be considered online. $failure_callback, // callable failure_callback - Allows the user to specify a callback function to run upon encountering an error. The callback is run before failover is attempted. The function takes two parameters, the hostname and port of the failed server. $timeoutms // int timeoutms ); // Return Values // Returns true on success or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::addServer() example // [php] // // // OO API // // $memcache = new Memcache; // $memcache->addServer('memcache_host', 11211); // $memcache->addServer('memcache_host2', 11211); // // // procedural API // // $memcache_obj = memcache_connect('memcache_host', 11211); // memcache_add_server($memcache_obj, 'memcache_host2', 11211); // // [/php] // [/example] // [/examples] // // Notes // Warning: When the port is unspecified, this method defaults to the value set of the PHP ini directive memcache.default_port If this value was changed elsewhere in your application it might lead to unexpected results: for this reason it is wise to always specify the port explicitly in this method call. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.addserver.php // ========== MEMCACHE_ADDSERVER - END // SYNTAX: // bool Memcache::addServer(string $host, int $port, bool $persistent, int $weight, int $timeout, int $retry_interval, bool $status, callable $failure_callback, int $timeoutms) return $return_memcache_addserver; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_ADDSERVER // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_CLOSE // ============================== PUBLIC // ============================== ABOUT // Close memcached server connection. // ============================== SUPPORT // PECL_memcache_0_4_0 // ============================== USING SUBCLASSES (1) // Memcache::close() - PECL_memcache >= PECL_memcache_0_4_0 // ============================== CODE function php_other_memcache_memcache_close($memcache) { $return_memcache_close = false; // ========== MEMCACHE_CLOSE - BEGIN // ===== ABOUT // Close memcached server connection // ===== DESCRIPTION // Memcache::close() closes connection to memcached server. This function doesn't close persistent connections, which are closed only during web-server shutdown/restart. Also you can use memcache_close() function. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_4_0 // ===== SYNTAX // Memcache::close(): bool // ===== CODE $return_memcache_close = $memcache->close( // This function has no parameters. ); // Return Values // Returns true on success or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::close() example // [php] // // // procedural API // $memcache_obj = memcache_connect('memcache_host', 11211); // // // // do something here... // // // memcache_close($memcache_obj); // // // OO API // $memcache_obj = new Memcache; // $memcache_obj->connect('memcache_host', 11211); // // // // do something here... // // // $memcache_obj->close(); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.close.php // ========== MEMCACHE_CLOSE - END // SYNTAX: // bool Memcache::close() return $return_memcache_close; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_CLOSE // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_CONNECT // ============================== PUBLIC // ============================== ABOUT // Open memcached server connection. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING SUBCLASSES (1) // Memcache::connect() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_connect($memcache, $host, $port, $timeout) { $return_memcache_connect = false; // ========== MEMCACHE_CONNECT - BEGIN // ===== ABOUT // Open memcached server connection // ===== DESCRIPTION // Memcache::connect() establishes a connection to the memcached server. The connection, which was opened using Memcache::connect() will be automatically closed at the end of script execution. Also you can close it with Memcache::close(). Also you can use memcache_connect() function. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_2_0 // ===== SYNTAX // Memcache::connect(string $host, int $port = ?, int $timeout = ?): bool // ===== CODE $return_memcache_connect = $memcache->connect( $host, // string host - Point to the host where memcached is listening for connections. This parameter may also specify other transports like unix:///path/to/memcached.sock to use UNIX domain sockets, in this case port must also be set to 0. $port, // int port - Point to the port where memcached is listening for connections. Set this parameter to 0 when using UNIX domain sockets. // Please note: port defaults to memcache.default_port if not specified. For this reason it is wise to specify the port explicitly in this method call. $timeout // int timeout - Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow. ); // Return Values // Returns true on success or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::connect() example // [php] // // // procedural API // // $memcache_obj = memcache_connect('memcache_host', 11211); // // // OO API // // $memcache = new Memcache; // $memcache->connect('memcache_host', 11211); // // [/php] // [/example] // [/examples] // // Notes // Warning: When the port is unspecified, this method defaults to the value set of the PHP ini directive memcache.default_port If this value was changed elsewhere in your application it might lead to unexpected results: for this reason it is wise to always specify the port explicitly in this method call. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.connect.php // ========== MEMCACHE_CONNECT - END // SYNTAX: // bool Memcache::connect(string $host, int $port, int $timeout) return $return_memcache_connect; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_CONNECT // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_DECREMENT // ============================== PUBLIC // ============================== ABOUT // Decrement item's value. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING SUBCLASSES (1) // Memcache::decrement() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_decrement($memcache, $key, $value = 1) { $return_memcache_decrement = false; // ========== MEMCACHE_DECREMENT - BEGIN // ===== ABOUT // Decrement item's value // ===== DESCRIPTION // Memcache::decrement() decrements value of the item by value. Similarly to Memcache::increment(), current value of the item is being converted to numerical and after that value is subtracted. // Note: New item's value will not be less than zero. // Note: Do not use Memcache::decrement() with item, which was stored compressed, because consequent call to Memcache::get() will fail. // Memcache::decrement() does not create an item if it didn't exist. Also you can use memcache_decrement() function. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_2_0 // ===== SYNTAX // Memcache::decrement(string $key, int $value = 1): int|false // ===== CODE $return_memcache_decrement = $memcache->decrement( $key, // string key - Key of the item do decrement. $value // int value - Decrement the item by value. ); // Return Values // Returns item's new value on success or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::decrement() example // [php] // // // procedural API // $memcache_obj = memcache_connect('memcache_host', 11211); // // decrement item by 2 // $new_value = memcache_decrement($memcache_obj, 'test_item', 2); // // // OO API // $memcache_obj = new Memcache; // $memcache_obj->connect('memcache_host', 11211); // // decrement item by 3 // $new_value = $memcache_obj->decrement('test_item', 3); // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.decrement.php // ========== MEMCACHE_DECREMENT - END // SYNTAX: // int|false Memcache::decrement(string $key, int $value = 1) return $return_memcache_decrement; // int|false } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_DECREMENT // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_DELETE // ============================== PUBLIC // ============================== ABOUT // Delete item from the server. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING SUBCLASSES (1) // Memcache::delete() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_delete($memcache, $key, $timeout = 0) { $return_memcache_delete = false; // ========== MEMCACHE_DELETE - BEGIN // ===== ABOUT // Delete item from the server // ===== DESCRIPTION // Memcache::delete() deletes an item with the key. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_2_0 // ===== SYNTAX // Memcache::delete(string $key, int $timeout = 0): bool // ===== CODE $return_memcache_delete = $memcache->delete( $key, // string key - The key associated with the item to delete. $timeout // int timeout - This deprecated parameter is not supported, and defaults to 0 seconds. Do not use this parameter. ); // Return Values // Returns true on success or false on failure. // // Changelog // Version - Description // Unknown - It's not recommended to use the timeout parameter. The behavior differs between memcached versions, but setting to 0 is safe. Other values for this deprecated feature may cause the memcache delete to fail. // // [examples] // Examples // [example] // Example #1 Memcache::delete() example // [php] // // // procedural API // $memcache_obj = memcache_connect('memcache_host', 11211); // // // item will be deleted by the server // memcache_delete($memcache_obj, 'key_to_delete'); // // // OO API // $memcache_obj = new Memcache; // $memcache_obj->connect('memcache_host', 11211); // // $memcache_obj->delete('key_to_delete'); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.delete.php // ========== MEMCACHE_DELETE - END // SYNTAX: // bool Memcache::delete(string $key, int $timeout = 0) return $return_memcache_delete; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_DELETE // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_FLUSH // ============================== PUBLIC // ============================== ABOUT // Flush all existing items at the server. // ============================== SUPPORT // PECL_memcache_1_0_0 // ============================== USING SUBCLASSES (1) // Memcache::flush() - PECL_memcache >= PECL_memcache_1_0_0 // ============================== CODE function php_other_memcache_memcache_flush($memcache) { $return_memcache_flush = false; // ========== MEMCACHE_FLUSH - BEGIN // ===== ABOUT // Flush all existing items at the server // ===== DESCRIPTION // Memcache::flush() immediately invalidates all existing items. Memcache::flush() doesn't actually free any resources, it only marks all the items as expired, so occupied memory will be overwritten by new items. Also you can use memcache_flush() function. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_1_0_0 // ===== SYNTAX // Memcache::flush(): bool // ===== CODE $return_memcache_flush = $memcache->flush( // This function has no parameters. ); // Return Values // Returns true on success or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::flush() example // [php] // // // procedural API // $memcache_obj = memcache_connect('memcache_host', 11211); // // memcache_flush($memcache_obj); // // // OO API // // $memcache_obj = new Memcache; // $memcache_obj->connect('memcache_host', 11211); // // $memcache_obj->flush(); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.flush.php // ========== MEMCACHE_FLUSH - END // SYNTAX: // bool Memcache::flush() return $return_memcache_flush; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_FLUSH // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_GET // ============================== PUBLIC // ============================== ABOUT // Retrieve item from the server. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING SUBCLASSES (1) // Memcache::get() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_get($memcache, $key, & $flags) { $return_memcache_get = null; // ========== MEMCACHE_GET - BEGIN // ===== ABOUT // Retrieve item from the server // ===== DESCRIPTION // Memcache::get() returns previously stored data of an item, if such key exists on the server at this moment. // You can pass array of keys to Memcache::get() to get array of values. The result array will contain only found key-value pairs. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_2_0 // ===== SYNTAX // Memcache::get(string $key, int &$flags = ?): string // // Memcache::get(array $keys, array &$flags = ?): array // ===== CODE $return_memcache_get = $memcache->get( $key, // string key - The key or array of keys to fetch. $flags // int& flags - If present, flags fetched along with the values will be written to this parameter. These flags are the same as the ones given to for example Memcache::set(). The lowest byte of the int is reserved for pecl/memcache internal usage (e.g. to indicate compression and serialization status). ); // Return Values // Returns the value associated with the key or an array of found key-value pairs when key is an array. Returns false on failure, key is not found or key is an empty array. // // [examples] // Examples // [example] // Example #1 Memcache::get() example // [php] // // // procedural API // $memcache_obj = memcache_connect('memcache_host', 11211); // $var = memcache_get($memcache_obj, 'some_key'); // // // OO API // $memcache_obj = new Memcache; // $memcache_obj->connect('memcache_host', 11211); // $var = $memcache_obj->get('some_key'); // // // // // You also can use array of keys as a parameter. // // If such item wasn't found at the server, the result // // array simply will not include such key. // // // // // procedural API // $memcache_obj = memcache_connect('memcache_host', 11211); // $var = memcache_get($memcache_obj, Array('some_key', 'another_key')); // // // OO API // $memcache_obj = new Memcache; // $memcache_obj->connect('memcache_host', 11211); // $var = $memcache_obj->get(Array('some_key', 'second_key')); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.get.php // ========== MEMCACHE_GET - END // SYNTAX: // string Memcache::get(string $key, int& $flags) return $return_memcache_get; // string } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_GET // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_GETEXTENDEDSTATS // ============================== PUBLIC // ============================== ABOUT // Get statistics from all servers in pool. // ============================== SUPPORT // PECL_memcache_2_0_0 // ============================== USING SUBCLASSES (1) // Memcache::getExtendedStats() - PECL_memcache >= PECL_memcache_2_0_0 // ============================== CODE function php_other_memcache_memcache_getextendedstats($memcache, $type, $slabid, $limit = 100) { $return_memcache_getextendedstats = null; // ========== MEMCACHE_GETEXTENDEDSTATS - BEGIN // ===== ABOUT // Get statistics from all servers in pool // ===== DESCRIPTION // Memcache::getExtendedStats() returns a two-dimensional associative array with server statistics. Array keys correspond to host:port of server and values contain the individual server statistics. A failed server will have its corresponding entry set to false. You can also use the memcache_get_extended_stats() function. // Note: This function has been added to Memcache version 2.0.0. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_2_0_0 // ===== SYNTAX // Memcache::getExtendedStats(string $type = ?, int $slabid = ?, int $limit = 100): array // ===== CODE $return_memcache_getextendedstats = $memcache->getExtendedStats( $type, // string type - The type of statistics to fetch. Valid values are {reset, malloc, maps, cachedump, slabs, items, sizes}. According to the memcached protocol spec these additional arguments "are subject to change for the convenience of memcache developers". $slabid, // int slabid - Used in conjunction with type set to cachedump to identify the slab to dump from. The cachedump command ties up the server and is strictly to be used for debugging purposes. $limit // int limit - Used in conjunction with type set to cachedump to limit the number of entries to dump. // Warning: The cachedump stat type has been removed from the memcached daemon due to security reasons. ); // Return Values // Returns a two-dimensional associative array of server statistics or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::getExtendedStats() example // [php] // $memcache_obj = new Memcache; // $memcache_obj->addServer('memcache_host', 11211); // $memcache_obj->addServer('failed_host', 11211); // // $stats = $memcache_obj->getExtendedStats(); // print_r($stats); // [/php] // The above example will output: // [result] // Array // ( // [memcache_host:11211] => Array // ( // [pid] => 3756 // [uptime] => 603011 // [time] => 1133810435 // [version] => 1.1.12 // [rusage_user] => 0.451931 // [rusage_system] => 0.634903 // [curr_items] => 2483 // [total_items] => 3079 // [bytes] => 2718136 // [curr_connections] => 2 // [total_connections] => 807 // [connection_structures] => 13 // [cmd_get] => 9748 // [cmd_set] => 3096 // [get_hits] => 5976 // [get_misses] => 3772 // [bytes_read] => 3448968 // [bytes_written] => 2318883 // [limit_maxbytes] => 33554432 // ) // // [failed_host:11211] => false // ) // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.getextendedstats.php // ========== MEMCACHE_GETEXTENDEDSTATS - END // SYNTAX: // array Memcache::getExtendedStats(string $type, int $slabid, int $limit = 100) return $return_memcache_getextendedstats; // array } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_GETEXTENDEDSTATS // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_GETSERVERSTATUS // ============================== PUBLIC // ============================== ABOUT // Returns server status. // ============================== SUPPORT // PECL_memcache_2_1_0 // ============================== USING SUBCLASSES (1) // Memcache::getServerStatus() - PECL_memcache >= PECL_memcache_2_1_0 // ============================== CODE function php_other_memcache_memcache_getserverstatus($memcache, $host, $port = 11211) { $return_memcache_getserverstatus = 0; // ========== MEMCACHE_GETSERVERSTATUS - BEGIN // ===== ABOUT // Returns server status // ===== DESCRIPTION // Memcache::getServerStatus() returns a the servers online/offline status. You can also use memcache_get_server_status() function. // Note: This function has been added to Memcache version 2.1.0. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_2_1_0 // ===== SYNTAX // Memcache::getServerStatus(string $host, int $port = 11211): int // ===== CODE $return_memcache_getserverstatus = $memcache->getServerStatus( $host, // string host - Point to the host where memcached is listening for connections. $port // int port - Point to the port where memcached is listening for connections. ); // Return Values // Returns a the servers status. 0 if server is failed, non-zero otherwise // // [examples] // Examples // [example] // Example #1 Memcache::getServerStatus() example // [php] // // // OO API // $memcache = new Memcache; // $memcache->addServer('memcache_host', 11211); // echo $memcache->getServerStatus('memcache_host', 11211); // // // procedural API // $memcache = memcache_connect('memcache_host', 11211); // echo memcache_get_server_status($memcache, 'memcache_host', 11211); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.getserverstatus.php // ========== MEMCACHE_GETSERVERSTATUS - END // SYNTAX: // int Memcache::getServerStatus(string $host, int $port = 11211) return $return_memcache_getserverstatus; // int } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_GETSERVERSTATUS // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_GETSTATS // ============================== PUBLIC // ============================== ABOUT // Get statistics of the server. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING SUBCLASSES (1) // Memcache::getStats() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_getstats($memcache, $type, $slabid, $limit = 100) { $return_memcache_getstats = false; // ========== MEMCACHE_GETSTATS - BEGIN // ===== ABOUT // Get statistics of the server // ===== DESCRIPTION // Memcache::getStats() returns an associative array with server's statistics. Array keys correspond to stats parameters and values to parameter's values. Also you can use memcache_get_stats() function. // ===== SUPPORTED // Memcache::getStats(string $type = ?, int $slabid = ?, int $limit = 100): array|false // ===== SYNTAX // PECL_memcache >= PECL_memcache_0_2_0 // ===== CODE $return_memcache_getstats = $memcache->getStats( $type, // string type - The type of statistics to fetch. Valid values are {reset, malloc, maps, cachedump, slabs, items, sizes}. According to the memcached protocol spec these additional arguments "are subject to change for the convenience of memcache developers". $slabid, // int slabid - Used in conjunction with type set to cachedump to identify the slab to dump from. The cachedump command ties up the server and is strictly to be used for debugging purposes. $limit // int limit - Used in conjunction with type set to cachedump to limit the number of entries to dump. ); // Return Values // Returns an associative array of server statistics or false on failure. // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.getstats.php // ========== MEMCACHE_GETSTATS - END // SYNTAX: // array|false Memcache::getStats(string $type, int $slabid, int $limit = 100) return $return_memcache_getstats; // array|false } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_GETSTATS // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_GETVERSION // ============================== PUBLIC // ============================== ABOUT // Return version of the server. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING SUBCLASSES (1) // Memcache::getVersion() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_getversion($memcache) { $return_memcache_getversion = false; // ========== MEMCACHE_GETVERSION - BEGIN // ===== ABOUT // Return version of the server // ===== DESCRIPTION // Memcache::getVersion() returns a string with server's version number. Also you can use memcache_get_version() function. // ===== SUPPORTED // Memcache::getVersion(): string|false // ===== SYNTAX // PECL_memcache >= PECL_memcache_0_2_0 // ===== CODE $return_memcache_getversion = $memcache->getVersion( // This function has no parameters. ); // Return Values // Returns a string of server version number or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::getVersion() example // [php] // // // OO API // $memcache = new Memcache; // $memcache->connect('memcache_host', 11211); // echo $memcache->getVersion(); // // // procedural API // $memcache = memcache_connect('memcache_host', 11211); // echo memcache_get_version($memcache); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.getversion.php // ========== MEMCACHE_GETVERSION - END // SYNTAX: // string|false Memcache::getVersion() return $return_memcache_getversion; // string|false } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_GETVERSION // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_INCREMENT // ============================== PUBLIC // ============================== ABOUT // Increment item's value. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING SUBCLASSES (1) // Memcache::increment() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_increment($memcache, $key, $value = 1) { $return_memcache_increment = false; // ========== MEMCACHE_INCREMENT - BEGIN // ===== ABOUT // Increment item's value // ===== DESCRIPTION // Memcache::increment() increments value of an item by the specified value. If item specified by key was not numeric and cannot be converted to a number, it will change its value to value. Memcache::increment() does not create an item if it doesn't already exist. // Note: Do not use Memcache::increment() with items that have been stored compressed because subsequent calls to Memcache::get() will fail. // Also you can use memcache_increment() function. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_2_0 // ===== SYNTAX // Memcache::increment(string $key, int $value = 1): int|false // ===== CODE $return_memcache_increment = $memcache->increment( $key, // string key - Key of the item to increment. $value // int value - Increment the item by value. ); // Return Values // Returns new items value on success or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::increment() example // [php] // // // procedural API // $memcache_obj = memcache_connect('memcache_host', 11211); // // increment counter by 2 // $current_value = memcache_increment($memcache_obj, 'counter', 2); // // // OO API // $memcache_obj = new Memcache; // $memcache_obj->connect('memcache_host', 11211); // // increment counter by 3 // $current_value = $memcache_obj->increment('counter', 3); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.increment.php // ========== MEMCACHE_INCREMENT - END // SYNTAX: // int|false Memcache::increment(string $key, int $value = 1) return $return_memcache_increment; // int|false } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_INCREMENT // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_PCONNECT // ============================== PUBLIC // ============================== ABOUT // Open memcached server persistent connection. // ============================== SUPPORT // PECL_memcache_0_4_0 // ============================== USING SUBCLASSES (1) // Memcache::pconnect() - PECL_memcache >= PECL_memcache_0_4_0 // ============================== CODE function php_other_memcache_memcache_pconnect($memcache, $host, $port, $timeout) { $return_memcache_pconnect = null; // ========== MEMCACHE_PCONNECT - BEGIN // ===== ABOUT // Open memcached server persistent connection // ===== DESCRIPTION // Memcache::pconnect() is similar to Memcache::connect() with the difference, that the connection it establishes is persistent. This connection is not closed after the end of script execution and by Memcache::close() function. Also you can use memcache_pconnect() function. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_4_0 // ===== SYNTAX // Memcache::pconnect(string $host, int $port = ?, int $timeout = ?): mixed // ===== CODE $return_memcache_pconnect = $memcache->pconnect( $host, // string host - Point to the host where memcached is listening for connections. This parameter may also specify other transports like unix:///path/to/memcached.sock to use UNIX domain sockets, in this case port must also be set to 0. $port, // int port - Point to the port where memcached is listening for connections. Set this parameter to 0 when using UNIX domain sockets. $timeout // int timeout - Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow. ); // Return Values // Returns a Memcache object or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::pconnect() example // [php] // // // procedural API // $memcache_obj = memcache_pconnect('memcache_host', 11211); // // // OO API // // $memcache_obj = new Memcache; // $memcache_obj->pconnect('memcache_host', 11211); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-10) // URL: https://www.php.net/manual/en/memcache.pconnect.php // ========== MEMCACHE_PCONNECT - END // SYNTAX: // mixed Memcache::pconnect(string $host, int $port, int $timeout) return $return_memcache_pconnect; // mixed } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_PCONNECT // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_REPLACE // ============================== PUBLIC // ============================== ABOUT // Replace value of the existing item. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING SUBCLASSES (1) // Memcache::replace() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_replace($memcache, $key, $var, $flag, $expire) { $return_memcache_replace = false; // ========== MEMCACHE_REPLACE - BEGIN // ===== ABOUT // Replace value of the existing item // ===== DESCRIPTION // Memcache::replace() should be used to replace value of existing item with key. In case if item with such key doesn't exists, Memcache::replace() returns false. For the rest Memcache::replace() behaves similarly to Memcache::set(). Also you can use memcache_replace() function. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_2_0 // ===== SYNTAX // Memcache::replace( // string $key, // mixed $var, // int $flag = ?, // int $expire = ? // ): bool // ===== CODE $return_memcache_replace = $memcache->replace( $key, // string key - The key that will be associated with the item. $var, // mixed var - The variable to store. Strings and integers are stored as is, other types are stored serialized. $flag, // int flag - Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib). $expire // int expire - Expiration time of the item. If it's equal to zero, the item will never expire. You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days). ); // Return Values // Returns true on success or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::replace() example // [php] // // $memcache_obj = memcache_connect('memcache_host', 11211); // // // procedural API // memcache_replace($memcache_obj, "test_key", "some variable", false, 30); // // // OO API // $memcache_obj->replace("test_key", "some variable", false, 30); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-11) // URL: https://www.php.net/manual/en/memcache.replace.php // ========== MEMCACHE_REPLACE - END // SYNTAX: // bool Memcache::replace(string $key, mixed $var, int $flag, int $expire) return $return_memcache_replace; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_REPLACE // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_SET // ============================== PUBLIC // ============================== ABOUT // Store data at the server. // ============================== SUPPORT // PECL_memcache_0_2_0 // ============================== USING SUBCLASSES (1) // Memcache::set() - PECL_memcache >= PECL_memcache_0_2_0 // ============================== CODE function php_other_memcache_memcache_set($memcache, $key, $var, $flag, $expire) { $return_memcache_set = false; // ========== MEMCACHE_SET - BEGIN // ===== ABOUT // Store data at the server // ===== DESCRIPTION // Memcache::set() stores an item var with key on the memcached server. Parameter expire is expiration time in seconds. If it's 0, the item never expires (but memcached server doesn't guarantee this item to be stored all the time, it could be deleted from the cache to make place for other items). You can use MEMCACHE_COMPRESSED constant as flag value if you want to use on-the-fly compression (uses zlib). // Note: Remember that resource variables (i.e. file and connection descriptors) cannot be stored in the cache, because they cannot be adequately represented in serialized state. // Also you can use memcache_set() function. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_0_2_0 // ===== SYNTAX // Memcache::set( // string $key, // mixed $var, // int $flag = ?, // int $expire = ? // ): bool // ===== CODE $return_memcache_set = $memcache->set( $key, // string key - The key that will be associated with the item. $var, // mixed var - The variable to store. Strings and integers are stored as is, other types are stored serialized. $flag, // int flag - Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib). $expire // int expire - Expiration time of the item. If it's equal to zero, the item will never expire. You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days). ); // Return Values // Returns true on success or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::set() example // [php] // // procedural API // // // connect to memcached server // $memcache_obj = memcache_connect('memcache_host', 11211); // // // // // set value of item with key 'var_key' // // using 0 as flag value, compression is not used // // expire time is 30 seconds // // // memcache_set($memcache_obj, 'var_key', 'some variable', 0, 30); // // echo memcache_get($memcache_obj, 'var_key'); // // [/php] // [/example] // [example] // Example #2 Memcache::set() example // [php] // // OO API // // $memcache_obj = new Memcache; // // // connect to memcached server // $memcache_obj->connect('memcache_host', 11211); // // // // // set value of item with key 'var_key', using on-the-fly compression // // expire time is 50 seconds // // // $memcache_obj->set('var_key', 'some really big variable', MEMCACHE_COMPRESSED, 50); // // echo $memcache_obj->get('var_key'); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-11) // URL: https://www.php.net/manual/en/memcache.set.php // ========== MEMCACHE_SET - END // SYNTAX: // bool Memcache::set(string $key, mixed $var, int $flag, int $expire) return $return_memcache_set; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_SET // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_SETCOMPRESSTHRESHOLD // ============================== PUBLIC // ============================== ABOUT // Enable automatic compression of large values. // ============================== SUPPORT // PECL_memcache_2_0_0 // ============================== USING SUBCLASSES (1) // Memcache::setCompressThreshold() - PECL_memcache >= PECL_memcache_2_0_0 // ============================== CODE function php_other_memcache_memcache_setcompressthreshold($memcache, $threshold, $min_saving) { $return_memcache_setcompressthreshold = false; // ========== MEMCACHE_SETCOMPRESSTHRESHOLD - BEGIN // ===== ABOUT // Enable automatic compression of large values // ===== DESCRIPTION // 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. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_2_0_0 // ===== SYNTAX // Memcache::setCompressThreshold(int $threshold, float $min_savings = ?): bool // ===== CODE $return_memcache_setcompressthreshold = $memcache->setCompressThreshold( $threshold, // int threshold - Controls the minimum value length before attempting to compress automatically. $min_saving // float 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] // Examples // [example] // 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); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-11) // URL: https://www.php.net/manual/en/memcache.setcompressthreshold.php // ========== MEMCACHE_SETCOMPRESSTHRESHOLD - END // SYNTAX: // bool Memcache::setCompressThreshold(int $threshold, float $min_savings) return $return_memcache_setcompressthreshold; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_SETCOMPRESSTHRESHOLD // ============================== // ============================== BEGIN // PHP_OTHER_MEMCACHE_MEMCACHE_SETSERVERPARAMS // ============================== PUBLIC // ============================== ABOUT // Changes server parameters and status at runtime. // ============================== SUPPORT // PECL_memcache_2_1_0 // ============================== USING SUBCLASSES (1) // Memcache::setServerParams() - PECL_memcache >= PECL_memcache_2_1_0 // ============================== CODE function php_other_memcache_memcache_setserverparams($memcache, $host, $port, $timeout, $retry_interval, $status, $failure_callback) { $return_memcache_setserverparams = false; // ========== MEMCACHE_SETSERVERPARAMS - BEGIN // ===== ABOUT // Changes server parameters and status at runtime // ===== DESCRIPTION // Memcache::setServerParams() changes server parameters at runtime. You can also use the memcache_set_server_params() function. // Note: This function has been added to Memcache version 2.1.0. // ===== SUPPORTED // PECL_memcache >= PECL_memcache_2_1_0 // ===== SYNTAX // Memcache::setServerParams( // string $host, // int $port = 11211, // int $timeout = ?, // int $retry_interval = false, // bool $status = ?, // callable $failure_callback = ? // ): bool // ===== CODE $return_memcache_setserverparams = $memcache->setServerParams( $host, // string host - Point to the host where memcached is listening for connections. $port, // int port - Point to the port where memcached is listening for connections. $timeout, // int timeout - Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow. $retry_interval, // int retry_interval - Controls how often a failed server will be retried, the default value is 15 seconds. Setting this parameter to -1 disables automatic retry. Neither this nor the persistent parameter has any effect when the extension is loaded dynamically via dl(). $status, // bool status - Controls if the server should be flagged as online. Setting this parameter to false and retry_interval to -1 allows a failed server to be kept in the pool so as not to affect the key distribution algorithm. Requests for this server will then failover or fail immediately depending on the memcache.allow_failover setting. Default to true, meaning the server should be considered online. $failure_callback // callable failure_callback - Allows the user to specify a callback function to run upon encountering an error. The callback is run before failover is attempted. The function takes two parameters, the hostname and port of the failed server. ); // Return Values // Returns true on success or false on failure. // // [examples] // Examples // [example] // Example #1 Memcache::setServerParams() example // [php] // // function _callback_memcache_failure($host, $port) { // print "memcache '$host:$port' failed"; // } // // // OO API // // $memcache = new Memcache; // // // Add the server in offline mode // $memcache->addServer('memcache_host', 11211, false, 1, 1, -1, false); // // // Bring the server back online // $memcache->setServerParams('memcache_host', 11211, 1, 15, true, '_callback_memcache_failure'); // // // procedural API // // $memcache_obj = memcache_connect('memcache_host', 11211); // memcache_set_server_params($memcache_obj, 'memcache_host', 11211, 1, 15, true, '_callback_memcache_failure'); // // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-11) // URL: https://www.php.net/manual/en/memcache.setserverparams.php // ========== MEMCACHE_SETSERVERPARAMS - END // SYNTAX: // bool Memcache::setServerParams(string $host, int $port, int $timeout, int $retry_interval, bool $status, callable $failure_callback) return $return_memcache_setserverparams; // bool } // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE_SETSERVERPARAMS // ============================== // ============================== END // PHP_OTHER_MEMCACHE_MEMCACHE // ============================== // ============================== END // PHP_OTHER_MEMCACHE // ============================== ?>