I using symfony 2 and I want to use Memcache with it but the problem is I can't find any explain for Memcache I just found for memcached so are they the same setup steps ? I added this lines to install Memcache on symfony?
config.yml
framework:
session:
handler_id: session.handler.memcached
for parameters.yml
parameters:
memcached_host: 127.0.0.1
memcached_port: 11211
memcached_prefix: custom_key_
memcached_expire: 14400
services.yml
services:
session.handler.memcached:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
arguments: [ "@session.memcached", { prefix: '%memcached_prefix%', expiretime: '%memcached_expire%' } ]
services:
session.memcached:
class: Memcached
arguments:
persistent_id: %memcached_prefix%
calls:
- [ addServer, [ %memcached_host%, %memcached_port% ]]
services:
session.memcached:
class: Madisoft\AppBundle\Utils\MemcachedWrapper
arguments:
persistent_id: '%memcached_prefix%'
calls:
- [ addServer, [ '%memcached_host%', '%memcached_port%' ] ]
First, when memcached gets full, it will start removing items from the cache using the Least Recently Used algorithm. Second, you can have multiple instances of memcached running, adding them gets complicated because it will change the hashing algorithm used to determine which cache the data is in.
How does Memcached work? Unlike databases that store data on disk or SSDs, Memcached keeps its data in memory. By eliminating the need to access disks, in-memory key-value stores such as Memcached avoid seek time delays and can access data in microseconds.
The Cache component provides features covering simple to advanced caching needs. It natively implements PSR-6 and the Cache Contracts for greatest interoperability. It is designed for performance and resiliency, ships with ready to use adapters for the most common caching backends.
There is only one Memcached
software, and it's the one available at https://memcached.org/.
There are two well-known PHP
libraries for Memcached
, called memcache
(http://php.net/manual/en/book.memcache.php) and memcached
(http://php.net/manual/en/book.memcached.php), so this is probably where your confusion comes from.
To use Memcached
with Symfony 2 I suggest to use an external bundle by LeaseWeb which provides all the required documentation: https://github.com/LeaseWeb/LswMemcacheBundle.
Starting with Symfony 3.3 there will be a native Memcached
adapter: see http://symfony.com/blog/new-in-symfony-3-3-memcached-cache-adapter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With