0

I am adding Memcached to my app and despite some very confusing setup and apparent duplicate it seemed to work, if only barely.

Then I needed to clear the cache after some changes using

./bin/console cache:clear --env=dev ( or =prod )

That's when I got the error:

[Symfony\Component\Cache\Exception\CacheException]
Memcached >= 2.2.0 is required

Well, according to phpinfo(), the Memcached version I've installed is 3.0.4, so I am not sure where that error is coming from.

EDIT: Adding that I am have also got the error below when attempting the cache:clear command:

PHP Fatal error: Class 'Memcached' not found in /Users/user/Sites/Symfony1/vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Fixtures/Memcached.php on line 6

As said the configuration is not at all clear. There's apparent overlap and my research on SO and elsewhere did not help much.

Also, I am using the memcached adapter on the Controller like so:

use Symfony\Component\Cache\Adapter\MemcachedAdapter;

which comes from Symfony's cache component, which does not seem to require any configuration on config.yml.

In any case, here's the configuration cache wise.:

/app/config.yml

framework:
    cache: 
        app: cache.adapter.memcached 
        default_memcached_provider: "memcached://127.0.0.1:11211"
...
orm:
    ...
    entity_managers:
        default:
            metadata_cache_driver: memcached
            result_cache_driver:
                type: memcached
                host: 127.0.0.1
                port: 11211
                instance_class: Memcached
            query_cache_driver: memcached

doctrine_cache:
    aliases: 
        mem_cached_meta: my_memcached_cache_metadata
        mem_cached_query: my_memcached_cache_query
        mem_cached_result: my_memcached_cache_result
    providers:
        my_memcached_cache_metadata: 
            type: memcached
            namespace: metadata_cache_ns
            aliases: 
                - mem_cached_meta
        my_memcached_cache_query: 
            type: memcached
            namespace: query_cache_ns
            aliases: 
                - mem_cached_query
        my_memcached_cache_result: 
            type: memcached
            namespace: result_cache_ns
            aliases: 
                - mem_cached_result
BernardA
  • 1,391
  • 19
  • 48
  • Do you have memcached extension enabled for php cli? – Iwan Wijaya Mar 21 '18 at 14:44
  • Well, not sure what do you mean by php cli. But memcached is installed and actually working. I've been able to cache and retrieve query results. – BernardA Mar 21 '18 at 14:48
  • Check [this](https://stackoverflow.com/a/1171351/1537154) answer for enabling memcache on the cli – Jeroen Mar 21 '18 at 21:30
  • Thanks @Jeroen, memcached is already working on cli. That's how I start its server ( memcached -l 127.0.0.1:11211 ) and it also shows with php -m. – BernardA Mar 22 '18 at 08:30

0 Answers0