GithubHelp home page GithubHelp logo

doctrine / doctrinecachebundle Goto Github PK

View Code? Open in Web Editor NEW
2.8K 28.0 85.0 284 KB

Symfony2 Bundle for Doctrine Cache

Home Page: http://www.doctrine-project.org

License: MIT License

PHP 100.00%
symfony symfony-bundle cache doctrine

doctrinecachebundle's Introduction

DoctrineCacheBundle

Symfony Bundle for Doctrine Cache.

Master: Build Status

Master: Coverage Status

Deprecation warning

This bundle is abandoned and will no longer be updated. If you want to use doctrine/cache in Symfony, please configure the services manually. When using Symfony, we no longer recommend configuring doctrine/cache through this bundle. Instead, you should use symfony/cache for your cache needs. However, the deprecation does not extend to doctrine/cache, you'll be able to use those classes as you did so far.

doctrinecachebundle's People

Contributors

77web avatar alcaeus avatar cdaguerre avatar chalasr avatar dragonwize avatar emanueleminotto avatar fabiobatsilva avatar fabpot avatar guilhermeblanco avatar hanikesn avatar ivoba avatar javiereguiluz avatar jean-beru avatar jwage avatar magnetik avatar maximium avatar mente avatar mikesimonson avatar nicolas-grekas avatar ocramius avatar opalenet-yann avatar prgtw avatar remicollet avatar sander-toonen avatar senseexception avatar stof avatar weaverryan avatar willemstuursma avatar xavierleune avatar yethee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doctrinecachebundle's Issues

ClassNotFoundException on DQL when cache is present

I first got this issue after updating to 1.0.1, then I reverted to 1.0.0 and it disappeared. Then I updated back to 1.0.1 and can't repeat it anymore, but it persisted after removing vendor folder and doing composer install, I'm not sure what has changed since.

This only happened in dev environment.

I've started to get this error in getResult() method on DQL-query:

Attempted to load class "SubCategory" from namespace "Proxies\__CG__\ProjectName\MainBundle\Entity".

I found two things that temporary fixed this issue:

  1. Removing annotations cache, particularly one cache file (its contents below)
  2. Removing a JOIN of entity that was in this file (ProductImage) from DQL query

But every time this cache file was regenerated, error repeated, This is what was in the file:

<?php return unserialize('a:2:{i:0;O:27:"Doctrine\\ORM\\Mapping\\Entity":2:{s:15:"repositoryClass";N;s:8:"readOnly";b:0;}i:1;O:26:"Doctrine\\ORM\\Mapping\\Table":5:{s:4:"name";s:14:"product_images";s:6:"schema";N;s:7:"indexes";N;s:17:"uniqueConstraints";N;s:7:"options";a:0:{}}}');

Entity ProductImage was not directly related to SubCategory, only via Product entity, in repository of which this error happened.

I use php 5.5.14 on Windows 8 x64

I hope this might help somehow, if no, feel free to close the issue, since I'm not able to repeat it anymore.

Illegal offset type in isset or empty - double call to $this->get()

I'm trying to configure DoctrineCacheBundle with MongoDB, however whenever I get the service from Symfony DI it results in the following PHP Warning:

Warning: Illegal offset type in isset or empty

Here is my config:

# Doctrine cache
doctrine_cache:
    providers:
        cake:
            type: mongodb
            namespace: cake
            mongodb:
                server: "%mongodb_server%"
                database_name: "dbname"
                collection_name: "cache"

And in my Controller:

$this->get('doctrine_cache.providers.cake')

After some debugging I have tracked it down to the file app/cache/dev/appDevDebugProjectContainer.php which contains the following code:

    protected function getDoctrineCache_Providers_CakeService()
    {
        $this->services['doctrine_cache.providers.cake'] = $instance = new \Doctrine\Common\Cache\MongoDBCache($this->get($this->get('doctrine_cache.services.cake.connection'))->selectCollection('dbname', 'cache'));

        $instance->setNamespace('cake');

        return $instance;
    }

The issue is the double $this->get($this->get()) as it's trying to pass an instance of MongoClient to the outer $this->get() call.

From what I can see the configuration is correct and it appears to be a bug within the following file which ultimately generates the above getDoctrineCache_Providers_CackeService method, however I can't work out what's causing it.

https://github.com/doctrine/DoctrineCacheBundle/blob/master/DependencyInjection/Definition/MongodbDefinition.php#L43

Removing the 2nd call to $this->get() resolves the issue and everything works as it should.

Thoughts?

Can not define Predis scheme config.yml for cache drivers

[Symfony\Component\Debug\Exception\ContextErrorException]
Notice: Undefined index: scheme in /vendor/doctrine/doctrine-cache-bundle/DependencyInjection/Definition/PredisDefinition.php line 49

possibly after 8290005

\app\config\config.yml

    orm:
        entity_managers:
            default:
                second_level_cache:
                    region_cache_driver:
                        type: predis
                    enabled: true

Disable custom cache?

Hello!

Thank you for this great bundle!

But, is it possible to disable the specific cache?

For example I want to disable some cache in development environment. I can't see such an option in the docs.

Thanks!

Persistent connections exhaust connections to memcached server

Hi,
when persistent connection to memcached is used, it behaves incorrectly and creates more and more persistent connections to memcached, which may lead to memcache connection limit exhausting in a short while.

The problem was introduced in #83 with version 1.3.0.

The issue is in MemcachedDefinition:

        if (isset($config['persistent_id']) === true) {
            $connDef->addrgument($config['persistent_id']);
        }

        foreach ($config['servers'] as $host => $server) {
            $connDef->addMethodCall('addServer', array($host, $server['port']));
        }

The addMethodCall('addServer', ...) adds new server(s) to the connection pool. This is not a problem without the persistent connection, because the pool is created only for the one request and the connection is closed shortly afterwards.

However, when the connection is created as persistent, servers are added to already existing pool, so after a while, you ends with many (same) memcached servers in the connection pool and new persistent connection being created to them every time new server from the pool is chosed. As the connections are created as persistent and new servers are added every request, it easily reaches almost any connection limit the memcached server has.

The addServer() should be IMHO called only if the Memcached instance does not contain the server setup yet (eg. count($memcached->getServerList()) is 0).

integrate Predis provider & cache v1.4

in doctrine cache 1.4 predis driver got added.
would be great if it could be integrated here as well.

ill try to make PR but if someone is faster, you are welcome.

Add persistend Id to memcached configuration

Hi,

Memcached supports a "persistent ID" as parameter for the constructor.
As we are moving to DoctrineCache in our datamapper ting, and we need this parameter, I'm implementing it in DoctrineCacheBundle.

Will you accept the pull request and then release it ?

Built-in provider complains about non-existing class

Hi,

this very simple test definition:

doctrine_cache:
  providers:
    my_memcache:
      type: memcache

Gives me an exception:

ReflectionException in ContainerBuilder.php line 964:
Class does not exist

in ContainerBuilder.php line 964
at ReflectionClass->__construct('') in ContainerBuilder.php line 964
at ContainerBuilder->createService(object(DefinitionDecorator), 'doctrine_cache.providers.my_memcache') in ContainerBuilder.php line 490

As far as I've seen it, it uses an abstract built-in definition for memcache that actually has a class in its definition. Still, it fails with the message mentioned.

Anyone seeing the error?

Cache drivers configuration doesn't work for most of the drivers

Hello,

First of all, consider that I didn't load the DoctrineCacheBundle (I only use DoctrineBundle) but the bug is from the code of DoctrineCacheBundle, that's why I post this issue here. And it's related to #38.

I notice that the SymfonyBridgeAdapter doesnt work for all cache definition and so it fails for example on file_system. The problem is that the configuration is faked only for memcached and redis (apc will work because there is no config needed). Others will fail.

Of course there is a workaround using the doctrine_cache configuration to create a provider and some config inside DoctrineBundle. But why keeping something that fails while you could suggest to use the other way ? I suggest to throw an exception more understandable while the cache driver is not supported by the SymfonyBridgeAdapter. Another solution is to fix the problem for all cache drivers.

(I can do it if you want)

Here is the configuration that should work but throw a PHP error:

doctrine:
    orm:
        result_cache_driver:
            type: file_system

Provider alias

Add support for provider alias

Example configuration :

doctrine_cache:
    alias:
       my_apc_cache_alias_foo: my_apc_cache
       my_apc_cache_alias_bar: my_apc_cache

    providers:
        my_apc_cache:
            type: apc
            namespace: my_apc_ns

Redis fetch multiple looks up cached values by cache key, lib returns by numeric ID

doFetchMultiple in RedisCache looks up the returned values by cache key, but the implementation docs say items are returned with numeric IDs corresponding to key order:

 /**
     * Returns the values of all specified keys.
     *
     * For every key that does not hold a string value or does not exist,
     * the special value false is returned. Because of this, the operation never fails.
     *
     * @param array $array
     * @return array
     * @link http://redis.io/commands/mget
     * @example
     * <pre>
     * $redis->delete('x', 'y', 'z', 'h');  // remove x y z
     * $redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'));
     * $redis->hset('h', 'field', 'value');
     * var_dump($redis->mget(array('x', 'y', 'z', 'h')));
     * // Output:
     * // array(3) {
     * // [0]=>
     * // string(1) "a"
     * // [1]=>
     * // string(1) "b"
     * // [2]=>
     * // string(1) "c"
     * // [3]=>
     * // bool(false)
     * // }
     * </pre>
     */

so the lookup always results in a miss

How to configure Redis provider?

Hi,

I'm try this config:

doctrine_cache:
    providers:
        redis_cache:
            redis:
                host: localhost
                port: 6379

And I'm using calling $cache = $this->container->get('doctrine_cache.providers.redis_cache');.

In development is OK, but in production throw error:
Fatal error: Class 'Redis' not found in (...)/app/cache/prod/appProdProjectContainer.php on line 693.

Where is the mistake?

Thank's!

DoctrineCacheBundle with Redis server went away

Error:
app/cache/dev/appDevDebugProjectContainer.php - Linea: 880 - Redis server went away

I am using this bundle and what happens to me is that when the doctrine server is down the application stops working throwing me a 500 error. The idea would be that if the redis server is down, continue the program reading from the database, but this is not so because it gives me the error reported from the symfony log.

I currently have it injected as follows:

Global.utils:
        Class: \ Common \ Utils
        arguments: ["@ doctrine_cache.providers.redis"]

And I use the following functions to verify the existence of cache and to save in it:

 Public function checkSiExistEnCache ($ key)
    {
try {
     $ redisCache-> setNamespace ('space-cache');
    return $redisCache->fetch($key);
} catch (\Exception $e) {
            //@todo logger
            $this->logger->crit("Redis is down!!! on check");
            return false;
        }
}

Public function saveEnCache ($ key, $ data, $ ttl)
{
try {

$ redisCache-> setNamespace ('scrutiny-cache');
            $ redisCache-> save ($ key, $ data, $ ttl);

}
catch (\Exception $e) {
            //@todo logger
            $this->logger->crit("Redis is down!!! on save");
            return false;
        }

I can not capture the exeption.

Now if instead of placing it in the service container services.YML
I get it through:

global.utils:
        class: \Common\Utils        
        arguments: ["@service_container","@logger"]

public function chequearSiExisteEnCache($key)
{

    try {

        $redisCache = $this->container->get("doctrine_cache.providers.redis");
        $redisCache->setNamespace('escrutinio-cache');

        return $redisCache->fetch($key);

    } catch (\Exception $e) {
        //@todo logger
        $this->logger->crit("Redis is down!!! on check");
        return false;
    }

}

Public function saveEnCache ($ key, $ data, $ ttl)
{
try {
$ redisCache = $ this-> container-> get ("doctrine_cache.providers.redis");
            $ redisCache-> setNamespace ('space-cache');

            return $ redisCache-> fetch ($ key);

} catch (\Exception $e) {
            //@todo logger
            $this->logger->crit("Redis is down!!! on save");
            return false;
        }

}

I can capture the exeption!!!

Here if I can capture the exeption and return true or false and continue reading the database if redis would be dropped.

What I would like to know is if this would be affecting the performance of the program, since every time I check the existence of cache, I am instantiating the bundle of redis and perhaps creating too many connections.

With the same bundle but using memcache I did not have this problem.

thanks and regards
Luke!

Custom cache providers

Add support for custom cache providers

Example configuration :

doctrine_cache:
    custom_providers:
       my_custom_provider: # cache type
           prototype : "my_custom_provider_service"  # abstract service
           definition_class : "MyCustomProvideDefinition"  # optional Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition\CacheDefinition

    providers:
        my_custom_cache:
            my_custom_provider:
                custom_provide_config_foo: "..."
                custom_provide_config_bar: "..."

question: Metadata caching fails on PHP7 phpredis

Metadata caching fails on PHP7 phpredis because of igbinary.
So is there a way to change default RedisCache so that serializer is Redis::SERIALIZER_PHP and not
Redis::SERIALIZER_IGBINARY ?

I don't want to recompile a phpredis extension without igbinary in it.

1.0 release

@doctrine/team-doctrine2
@doctrine/team-symfony-integration
Any thing you guys what to add before we tag 1.0 release ?

Unrecognized options "directory, extension" when using "type: file_system"

I am trying to setup DoctrineCacheBundle.

Here is config:

doctrine_cache:
    providers:
        my_file_cache:
            type: file_system
            directory: "%kernel.root_dir%/cache"
            extension: cache

And result is:

InvalidConfigurationException in ArrayNode.php line 309: Unrecognized options "directory, extension" under "doctrine_cache.providers.my_file_cache"

Alias may not work well

For custom providers, if doctrine_cache.providers.select2_cache is a dependency service for other services, it may throw non existing service, see below:

doctrine_cache:

    # this works
    aliases:
        doctrine_cache.providers.select2_cache: data_cache

    custom_providers:
        doctrine_cache_predis:
            prototype:  "prefix.doctrine_cache_predis"

        data_cache:
            ........
            doctrine_cache_predis: ~
            # this will not work
            aliases:
                - doctrine_cache.providers.select2_cache

Test failures with latest symfony (2.8.21, 2.3.0)

Found in Fedora QA after update from 2.8.20 to 2.8.21 (everything was ok with previous version)
https://apps.fedoraproject.org/koschei/package/php-doctrine-doctrine-cache-bundle?collection=f27

Reproduced using git + composer (so with symfony 2.3.0)

$ vendor/bin/phpunit --verbose
PHPUnit 4.8.35 by Sebastian Bergmann and contributors.

Runtime:	PHP 7.0.19
Configuration:	/tmp/DoctrineCacheBundle/phpunit.xml.dist

............................................EEEEEE.SSSS.....S..

Time: 230 ms, Memory: 16.00MB

There were 6 errors:

1) Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command\ContainsCommandTest::testContainsFalse
Invalid argument supplied for foreach()

/tmp/DoctrineCacheBundle/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:105
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:141
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:124
/tmp/DoctrineCacheBundle/vendor/symfony/console/Application.php:90
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:43
/tmp/DoctrineCacheBundle/Tests/Functional/Command/CommandTestCase.php:53
/tmp/DoctrineCacheBundle/Tests/Functional/Command/ContainsCommandTest.php:30

2) Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command\ContainsCommandTest::testContainsTrue
Invalid argument supplied for foreach()

/tmp/DoctrineCacheBundle/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:105
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:141
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:124
/tmp/DoctrineCacheBundle/vendor/symfony/console/Application.php:90
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:43
/tmp/DoctrineCacheBundle/Tests/Functional/Command/CommandTestCase.php:53
/tmp/DoctrineCacheBundle/Tests/Functional/Command/ContainsCommandTest.php:30

3) Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command\DeleteCommandTest::testDeleteSuccess
Invalid argument supplied for foreach()

/tmp/DoctrineCacheBundle/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:105
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:141
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:124
/tmp/DoctrineCacheBundle/vendor/symfony/console/Application.php:90
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:43
/tmp/DoctrineCacheBundle/Tests/Functional/Command/CommandTestCase.php:53
/tmp/DoctrineCacheBundle/Tests/Functional/Command/DeleteCommandTest.php:30

4) Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command\DeleteCommandTest::testDeleteAll
Invalid argument supplied for foreach()

/tmp/DoctrineCacheBundle/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:105
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:141
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:124
/tmp/DoctrineCacheBundle/vendor/symfony/console/Application.php:90
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:43
/tmp/DoctrineCacheBundle/Tests/Functional/Command/CommandTestCase.php:53
/tmp/DoctrineCacheBundle/Tests/Functional/Command/DeleteCommandTest.php:30

5) Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command\FlushCommandTest::testFlush
Invalid argument supplied for foreach()

/tmp/DoctrineCacheBundle/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:105
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:141
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:124
/tmp/DoctrineCacheBundle/vendor/symfony/console/Application.php:90
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:43
/tmp/DoctrineCacheBundle/Tests/Functional/Command/CommandTestCase.php:53
/tmp/DoctrineCacheBundle/Tests/Functional/Command/FlushCommandTest.php:30

6) Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command\StatsCommandTest::testStats
Invalid argument supplied for foreach()

/tmp/DoctrineCacheBundle/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:105
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:141
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:124
/tmp/DoctrineCacheBundle/vendor/symfony/console/Application.php:90
/tmp/DoctrineCacheBundle/vendor/symfony/framework-bundle/Console/Application.php:43
/tmp/DoctrineCacheBundle/Tests/Functional/Command/CommandTestCase.php:53
/tmp/DoctrineCacheBundle/Tests/Functional/Command/StatsCommandTest.php:30

any way to view data cached in doctrine?

I found these commands related to doctrine cache, but no command to view data cached in doctrine? it there a way to do this?

 doctrine:cache:clear-metadata          
      doctrine:cache:clear-result            
      doctrine:cache:clear-query             
      doctrine:cache:contains                
      doctrine:cache:delete                  
      doctrine:cache:clear                   
      doctrine:cache:flush                   
      doctrine:cache:stats      

DBAL Cache Provider?

Hi,

I was wondering why there is no DBAL cache provider.
I would like to use it like the "SQLite3Cache", but just with a DBAL Connection instead of the "SQLite3".
Actually i build a custom provider, but it could be an official implementation.

Any thoughts about it?

Add support for AclCache

This would allow us to control situations like this: symfony/symfony#10328
By releasing a specific implementation of cache that covers ACL we allow this class to be deprecated fully and bring the responsibility to us.

Load all/multiple class metadata automatically [Discussion]

This PR doctrine/cache#29 Added functionality to perform multiple fetches on various cache implementations. Is there any scope for adding some sort of intelligent use of this within this bundle?

Thoughts:

  • Option to load all class metadata for a given entity manager eagerly?
  • Option to remember which class metadata was used (for a given route/service) and eagerly load it for subsequent requests?

I'm aware that I'm possibly optimising in the wrong area here so I'd be interested to hear if anyone else has similar problems (our application is quite large so the scope of some requests often means the loading of models from many parts of the systems). A well layered caching system means this isn't a terminal problem for us, but the latency/load associated with populating the metadata cache adds a significant overhead to most requests.

Give options to memcached driver

Hi,

Actually there is no clean way to call the method "setOptions" on the memcached instance. However this is very useful.
As an example when you have multiple memcached server, it's a very good practice do use a libkatema compatible hashing algorithm.

I'll push a PR about this lack.

Thanks !

Providers that relies on external configuration should also accept services

According to some configuration seen on RiakDefinition, it is possible to mix and match services as constructor arguments of cache providers.
The perfect example of this is the situation we face at @instaclick where we take advantage of ICBaseRiakBundle to create services for Connection and Bucket and we may want to create cache providers around them.
By taking this into consideration, I'd assume we could also write configuration like:

doctrine_cache:
    providers:
        default_result_cache:
            riak:
                namespace: 'foo'
                bucket:
                    id: 'ic_base_riak.bucket.result_cache'

Getting rid of a symfony/framework-bundle requirement

Currently this bundle requires symfony/framework-bundle because Doctrine\Bundle\DoctrineCacheBundle\Command\CacheCommand extends Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand. To not make an application which does not use symfony/framework-bundle but uses symfony/http-kernel component to install unnecessary bundle you can make CacheCommand an implementation of Symfony\Component\DependencyInjection\ContainerAwareInterface.

Memory leaks

I'm not able to create issues on doctrine/cache so I'll just leave it here.

Probably there are memoty leaks in the library doctrine/cache, I noticed similar issues with APC too. I used v1.3.0.

2014/12/05 15:39:13 [error] 15961#0: *72120 FastCGI sent in stderr: "PHP message : PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to a llocate 26593710 bytes) in /var/www/myhost.com/shared/vendor/doctrine/cache/ lib/Doctrine/Common/Cache/RedisCache.php on line 83" while reading response head er from upstream, client: 173.245.48.196, server: api.myhost.com, request: " GET /martinfabricius/likes/153 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "myhost.com"

Connections not closed during tests

I have a lot of behat features and I when using RedisCache, the number of connections to redis keep increasing until I get Too many open files.

Test suite fails with latest doctrine/cache (1.6.0)

Hi,

Running the testsuite while using the latest doctrine/cache (1.6.0) now fails:

$ phpunit -v Tests/Functional/Command/StatsCommandTest.php
PHPUnit 5.1.3 by Sebastian Bergmann and contributors.

Runtime:       PHP 5.6.16-2 with Xdebug 2.3.3
Configuration: /home/taffit/debian/php-doctrine-cache-bundle/phpunit.xml.dist

F                                                                   1 / 1 (100%)

Time: 163 ms, Memory: 11.75Mb

There was 1 failure:

1) Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command\StatsCommandTest::testStats
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Stats were not provided for the my_array_cache provider of type Doctrine\Common\Cache\ArrayCache
+'Stats for the my_array_cache provider of type Doctrine\Common\Cache\ArrayCache:
+[hits] 0
+[misses] 0
+[uptime] 1451787601
+[memory_usage] 
+[memory_available] 
 '

[…]/Tests/Functional/Command/StatsCommandTest.php:44

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

Regards

David

Memcached - missing class

Hi guys

Currently I have an issue about PHP Fatal error : Class 'Memcached' not found in ...

I have tested the DoctineCacheBundle of Symfony on XAMPP (Windows) and IDE is phpstorm.

for 1 week, I checked configuration as below.

Doctrine Cache

doctrine_cache:
providers:
service_connection_memcached_provider:
memcached:
connection_id: "memcached"

services:
memcached:
class: Memcached
calls:
- [ addServers, [ "%memcached_servers%" ]]
cache_memcached:
class: Doctrine\Common\Cache\MemcachedCache
calls:
- [ setMemcached, ['@memcached']]

parameters:
memcached_servers:
- { host: cache.amazonaws.com, port: 11211 }
- { host: cache.amazonaws.com, port: 11211 }

I think that this isssue is not in my notebook (XAMPP, PHPSTORM). because I'm using memcached servers on AWS (Amazon Web Service)

and I saw a message about missing class of Memcached on PHPSTORM.

Can you give me an advice ?

Regards

Ryan

Make security-acl an optional dependency

IMO the symfony/security-acl dependency should be moved from require to require-dev (and suggest).

We are trying to remove ACL from the default symfony installation, see symfony/symfony#14718
And symfony/symfony 3.0 does not require security-acl anymore and security-acl is also extracted into standalone repo since 2.8.

But using symfony-standard 3.0 still installs security-acl because the doctrine cache bundle requires it.

Missing namespace setting when using custom_provider

The normalizer code inside DepdencyInject/Configuration seems to have left out the namespace for customer providers.

It should be


if ($self->isCustomProvider($conf['type'], $builder->buildTree())) {
                $params  = $self->getProviderParameters($conf);
                $options = reset($params);
                $conf    = array(
                    'type'            => 'custom_provider',
                    'namespace'       => $conf['namespace'] ?: null, // this part was missing
                    'custom_provider' => array(
                        'type'      => $conf['type'],
                        'options'   => $options ?: null,
                    )
                );
            }

I can't configure DoctrineCacheBundle to work with Redis

Hello!
I'm trying to configure DoctrineCacheBundle to work with Redis.
I've installed DoctrineCacheBundle according to Installation page, then I've changed my config file config.yml:

doctrine:
    ...
    orm:
        ...
        metadata_cache_driver:
            type: redis
            host: 127.0.0.1
        query_cache_driver:
            type: redis
            host: 127.0.0.1
        result_cache_driver:
            type: redis
            host: 127.0.0.1

Now, through redis-cli, I can see some new keys in Redis, that are generated by DoctrineCacheBundle. For example:

  • DoctrineNamespaceCacheKey[sf2orm_default_cc97f00cfbaec05a97bfe2b8e97e19bbb86c6b60493b43afbb6b4f0e5a54055c]
  • sf2orm_default_cc97f00cfbaec05a97bfe2b8e97e19bbb86c6b60493b43afbb6b4f0e5a54055c[AppBundle\Entity\Location$CLASSMETADATA][1]

But when I'm trying to execute GET Redis command to get value for any of these keys, I see nil. When I turn redis-cli to monitor mode, I can see that DoctrineCacheBundle (while people are browsing my site) tries to execute SET Redis command to save some binary data (it looks like \x09c\x08b etc) to these keys. But GET for all these keys is always nil. Accordingly, I see through profiler, that cache is not working and all the requests come to MySQL server directly.

DoctrineCacheBundle 1.3
Symfony 3.0.3
PHP 7.0.4 with phpredis and igbinary extensions
Redis 3.0.7

Add option 'public' to cache providers

in case cache provider only use on other services argument, so i dont need that provider set as public service.

for example i use doctrine cache for caching the validation metadata

# service.yml
services:
    app.cache.validation:
        class: "Symfony\\Component\\Validator\\Mapping\\Cache\\DoctrineCache"
        arguments: ["@doctrine_cache.providers.validation_cache"]
        public: false

# config.yml
doctrine_cache:
    providers:
        validation_cache:
            namespace: "validation_cache:"
            redis:
                host: "..."
                port: "..."
                database: "..."

framework:
    validation:
        cache: app.cache.validation

the service doctrine_cache.providers.validation_cache just as other service arguments.

so i think it would be great if it can set as 'public' option

# config.yml
doctrine_cache:
    providers:
        validation_cache:
            namespace: "validation_cache:"
            redis:
                host: "..."
                port: "..."
                database: "..."
            public: false

Can not define Redis database in config.yml for cache drivers

We have a production Redis cache and would like to specify a database other than the default 0 (0-15 selectable in Redis). Specifying a database in config.yml causes InvalidConfigurationException in ArrayNode.php line 309.

doctrinecachebundle

# Doctrine Configuration
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        # if using pdo_sqlite as your database driver, add the path in parameters.yml
        # e.g. database_path: "%kernel.root_dir%/data/data.db3"
        # path:     "%database_path%"
        types:

    orm:
        metadata_cache_driver: 
            type: redis
            database: 8
            host: 192.168.0.1
        query_cache_driver:
            type: redis
            database: 8
            host: 192.168.0.1
        result_cache_driver:
            type: redis
            database: 8
            host: 192.168.0.1

contains always return TRUE - Provider Memcache 2.2.7

OS: windows 7
PHP Version 5.5.10
memcache Version 2.2.7

/* @var $cache \Doctrine\Common\Cache\CacheProvider */
$cache = $this->get('pro_cache');
$cache_id = 'user_data:'.$userId;
var_dump($cache->contains($cache_id)); // Return Always true
$cache->save($cache_id, 1, 300);

[RFC] Advanced cache wrapper

Hi all, could be interesting for this bundle to include (optionally) the CEikermann/advcache.

Configuration example:

doctrine_cache:
  providers:
    test:
      type: apc
      advanced: true

I'm looking for feedbacks before starting a PR.
Thanks

Memcache::delete always throws Notice

There is no possibility to open an issue on doctrine/cache, so I'll open it here.

I use Doctrine Cache Bundle with Memcache and, when I do this:

$memcache->setNamespace('mynamespace');
$memcache->save($mykey, 'some-data-here', 3600);
$result = $memcache->delete($mykey);

I always get the following Notice:

PHP Notice: MemcachePool::delete(): Server localhost (tcp 11211, udp 0) failed with: CLIENT_ERROR bad command line format. Usage: delete [noreply]

If I replace internally in the library this:

return $this->memcache->delete($id) || ! $this->doContains($id);

with this:

return $this->memcache->delete($id, 0) || ! $this->doContains($id);

Then I no longer get the notice.

This is quite interesting because, according to PHP documentation:

It's not recommended to use the timeout parameter.

Is anyone else experiencing this problem ? Or is it just me ? I suspect most people use memcache when using this library. So how come is it's not reported/fixed by now ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.