@@ -110,6 +110,102 @@ helper allows creating a connection to a Redis server using a DSN configuration:
110110
111111See the method's docblock for more options.
112112
113+ Memcached Cache Adapter
114+ ~~~~~~~~~~~~~~~~~~~~~~~
115+
116+ .. versionadded :: 3.3
117+ The Memcached adapter was introduced in Symfony 3.3.
118+
119+ This adapter stores the contents in the memory of a Memcached server. Unlike the
120+ APCu adapter, and similarly to the Redis adapter, it's not limited to the shared
121+ memory of the current server, so you can store contents independent of your PHP
122+ environment, including the ability to utilize a cluster of servers if needed.
123+
124+ .. tip ::
125+
126+ **Requirements: **
127+
128+ The Memcached PHP extension as well as the Memcached server daemon must be
129+ installed and active to use this adapter.
130+
131+ This adapter expects a ``\Memcached `` class instance passed as the first parameter
132+ during construction::
133+
134+ use Symfony\Component\Cache\Adapter\MemcachedAdapter;
135+
136+ $cache = new MemcachedAdapter(
137+ // the object that stores a valid connection to your Memcached system
138+ \Memcached $memcachedConnection,
139+ // the string prefixed to the keys of the items stored in this cache
140+ $namespace = '',
141+ // in seconds; applied to cache items that don't define their own lifetime
142+ // 0 means to store the cache items indefinitely (i.e. until the Memcached memory
143+ // contents are flushed or the daemon(s) restarted)
144+ $defaultLifetime = 0
145+ );
146+
147+ The :method: `Symfony\\ Component\\ Cache\\ Adapter\\ MemcachedAdapter::createConnection `
148+ helper method allows creating and configuring a ``\Memcached `` instance using a DSN
149+ or array of DSNs::
150+
151+ $memcachedConnection = MemcachedAdapter::createConnection('memcached://localhost');
152+
153+ $memcachedConnection = MemcachedAdapter::createConnection(array(
154+ 'memcached://localhost:11211?weight=25',
155+ 'memcached://localhost:11212?weight=25',
156+ 'memcached://localhost:11213?weight=50',
157+ ));
158+
159+ Passing ``weight `` is option, even when multiple servers are being registered. When no
160+ ``weight `` is passed, all servers are utilized equally. When passing the ``weight `` DSN
161+ option, servers with a higher value will be utilized more than those with lesser values.
162+
163+ .. note ::
164+
165+ **DSN Examples: **
166+
167+ A Memcached DSN can specify either a host (with an optional port) or socket path,
168+ as well as a ``weight `` and a ``persistent_id `` query value, using the following
169+ syntax:
170+
171+ .. code-block :: text
172+
173+ memcached://[ip|host|socket[:port]]?[weight=int]&[persistent_id=string]
174+
175+ For example, the below list provides examples of valid DSNs using different
176+ combinations of values:
177+
178+ .. code-block :: text
179+
180+ memcached://my.server.com:11211
181+ memcached://127.0.0.1?weight=50&persistent_id=my_persistent_id
182+ memcached:///var/run/memcached.sock
183+ memcached:///var/run/memcached.sock?weight=20
184+
185+ The :method: `Symfony\\ Component\\ Cache\\ Adapter\\ MemcachedAdapter::createConnection `
186+ helper method also accepts an array of options as its second argument::
187+
188+ $memcachedConnection = MemcachedAdapter::createConnection(array(
189+ // dsns...
190+ 'memcached://localhost:11211',
191+ 'memcached://localhost:11212',
192+ ), array(
193+ // options...
194+ 'compression' => true,
195+ 'hash' => 'md5',
196+ 'serializer' => 'igbinary',
197+ ));
198+
199+ Common options include:
200+
201+ * **compression **: bool
202+ * @todo: add options
203+
204+
205+
206+ See the :method: `Symfony\\ Component\\ Cache\\ Adapter\\ MemcachedAdapter::createConnection `
207+ method's docblock for more information about valid DSNs and options.
208+
113209PDO & Doctrine DBAL Cache Adapter
114210~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115211
0 commit comments