MemcachedAdapter.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Cache\Adapter;
  11. use Symfony\Component\Cache\Marshaller\MarshallerInterface;
  12. use Symfony\Component\Cache\Traits\MemcachedTrait;
  13. class MemcachedAdapter extends AbstractAdapter
  14. {
  15. use MemcachedTrait;
  16. protected $maxIdLength = 250;
  17. /**
  18. * Using a MemcachedAdapter with a TagAwareAdapter for storing tags is discouraged.
  19. * Using a RedisAdapter is recommended instead. If you cannot do otherwise, be aware that:
  20. * - the Memcached::OPT_BINARY_PROTOCOL must be enabled
  21. * (that's the default when using MemcachedAdapter::createConnection());
  22. * - tags eviction by Memcached's LRU algorithm will break by-tags invalidation;
  23. * your Memcached memory should be large enough to never trigger LRU.
  24. *
  25. * Using a MemcachedAdapter as a pure items store is fine.
  26. */
  27. public function __construct(\Memcached $client, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null)
  28. {
  29. $this->init($client, $namespace, $defaultLifetime, $marshaller);
  30. }
  31. }