Home >Backend Development >PHP Tutorial >Detailed explanation and simple application of PHP Memcache (1/2)_PHP tutorial
Introduction:
memcached is a high-performance, distributed memory object caching system. It is usually used to reduce the loading pressure of database tutorials to improve the response speed of dynamic web applications.
This extension uses the API provided by the libmemcached library to interact with the memcached server. It also provides a session handler (memcached). It also provides a session processor
More information about libmemcached can be viewed at http://libmemcached.org/libmemcached.html.
memcache requirements:
This extension requires the libmemcached client library.
memcache installation:
Information related to installing this pecl extension can be found in the manual chapter titled Installation of the pecl extension. Additional information such as new releases, downloads, source files, maintainer information and change logs are available here: http://pecl.phptutorial.net/package/memcached.
If libmemcached is installed in a non-standard path, use --with-libmemcached-dir=dir to specify the path. dir is the prefix parameter when installing libmemcached. This path needs to include the file include/libmemcached/memcached.h.
If you want to support compression, you need zlib. For non-standard installation of the zlib library, use --with-zlib-dir=dir to specify the zlib installation path. dir is the prefix parameter during zip installation.
Session processor support is enabled by default. If you want to turn it off, use option --disable-memcached-session.
Predefined constants:
The following constants are defined by this extension and are only available when this extension is compiled into php or dynamically loaded at runtime.
memcached::opt_compression
Enable or disable compression. When enabled, when the value of the item exceeds a certain threshold (currently 100 bytes), the value will first be compressed and then stored, and will be decompressed and returned when the value is obtained, making the compression transparent to the application layer.
Type: boolean, default: true.
memcached::opt_serializer
Specifies the serialization tool for serializing non-scalar values. Available values are memcached::serializer_php and memcached::serializer_igbinary. The latter is only effective when the --enable-memcached-igbinary option is enabled during memcached configuration and the igbinary extension is loaded.
Type: integer, default: memcached::serializer_php.
memcached::serializer_php
Default php serialization tool (i.e. serialize method).
1 2