Giter Site home page Giter Site logo

cache's People

Contributors

abacaphiliac avatar alcaeus avatar beberlei avatar daschl avatar deeky666 avatar derrabus avatar fabiobatsilva avatar grahamcampbell avatar greg0ire avatar guilhermeblanco avatar holtkamp avatar jeroendedauw avatar jmikola avatar jwage avatar lcobucci avatar localheinz avatar majkl578 avatar makasim avatar mikesul avatar nicolas-grekas avatar nresni avatar o avatar ocramius avatar olemchls avatar pavlepredic avatar reedy avatar rican7 avatar tobion avatar victorjonsson avatar yura3d 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cache's Issues

AutoExpiration index of MongoCollections not configured automatically

After switching to Doctrine\Cache using the MongoDBCache I noticed the MongoDB Collections were growing / expired entries were not removed automatically.

After having a look at the source, it seems the use of MongoDB's automatic purging functionality is not 'enforced'. Would it make sense to do this? Something like this which can be invoked in the constructor.

    private function createIndex()
    {
        $this->collection->createIndex(
            array(self::EXPIRATION_FIELD => 1),
            array(
                'background' => true, //Builds the index in the background so that building an index does not block other database activities.
                'expireAfterSeconds' => 0 // Have entries expire directly (0 seconds) after reaching expiration time
            )
        );
    }

Note that prior to MongoDB the function was called ensureIndex(), which is now an alias of createIndex(). Ensuring an index exists sounds more appropriate to me, but hey, it is deprecated ๐Ÿ˜„

Also see our previous cache driver: https://github.com/AntonStoeckl/Zend_Cache_Backend_Mongo/blob/aa1ac7cf415bb96fd114a9717e5ab88822462ed5/library/Zend/Cache/Backend/Mongo.php#L548-L567

PhpFileCache strange issues when used for Doctrine Annotations reader

We are experiencing strange issue with PhpFileCache used for caching Doctrine annotations.

Issue can be reproduced, here is the PR where we stumbled upon that issue goaop/framework#359

Here is the troubling piece of code: goaop/framework#359 (diff)

Namely, we have same configuration for all PHP versions. If we use PhpFileCache, test will fail on PHP 5.x, 7.0, passes on 7.1 and 7.2

If FilesystemCache is used, it passes on all PHP versions.

What I have managed to see from cache directory is that PhpFileCache does not creates cache records on filesystem.

I have to repeat again -> same configuration parameters are used for both drivers.

Broken php 5.6 support in minor version

Hi!
Let me understand how it works. Minor version update should not break back compatibility, should it? And since we have

doctrine/common  v2.7.3          requires  doctrine/cache (1.*)
doctrine/orm     v2.5.6          requires  doctrine/cache (~1.4)

means, project just collapse in php 5.6. Is there a way for me to be safe in feature?
Thank you.

RiakCache.php fails lint check in PHP7.2

lint:
    [apply] Fatal error: Cannot use Riak\Object as Object because 'Object' is a special class name in vendor/doctrine/cache/lib/Doctrine/Common/Cache/RiakCache.php on line 25
    [apply] Errors parsing vendor/doctrine/cache/lib/Doctrine/Common/Cache/RiakCache.php

I'm using the following composer.json file:

{
    "require": {
        "doctrine/cache": "~1.4"
    },
    "prefer-stable": true
}
$ php --version
PHP 7.2.0beta1 (cli)

Not possible to manually remove expired cache entries

To prevent caches from growing infinitely, expired entries should be removed. Some CacheProviders do this automatically, others don't.

As part of a maintenance task that is executed periodically, it would be nice to be able to cleanup a cache: remove all expired cache entries.

I noticed the existence of the following interfaces:

  • flushableCache
  • clearableCache

But was actually looking for an interface like:

interface cleanableCache{
    public function clean(DateTime $specificExpirationDateTimeNowOtherWise = null);
}

Is it on purpose that this kind of functionality is missing, or am I thinking in the wrong direction?

File cache names are too long. Checks limiting it to 255 do not actually work properly in all cases.

First of all, there was this issue posted for Symfony here: https://github.com/symfony/symfony/issues/19363 . I encountered the same thing and spent a lot of time investigating it and came up to this:
When using FileCache filenames sometimes are longer, than supported. I am using docker containers on vagrant with VBox linked shared folders. There is a limit for a FILE_NAME of 255 characters.
I tried renaming some of the long filenames inside cache directories and the error switched to another folder:
/var/www/html/var/cache/de~/annotations/fd -> var/www/html/var/cache/de~/annotations/44
for example. So it looks like command is able to process the first folder, but then fails on the second one, as there is also a very long filename (256 characters including extension, which should be 255).

I am using docker containers on vagrant with VirtualBox and I suspect that the vboxsf might have some FILE_NAME or PATH_NAME limitations and those are 255 and 4096 respectively.

Then I tried to reduce filenames from 256 chars and went to Doctrine\Common\Cache\FilesystemCache and changed extension from .doctrinecache.data to .doctrine.data and everything worked, I was able to clear the cache after clearing the previous one manually (it still had long files).

It led me to suspect, that the problem lies within Doctrine\Common\Cache\FileCache, getFilename() does not work properly and sometimes has wrong behaviour. I think this issue is also connected to #174 .

IMPORTANT: Issue persists only for Symfony dev environment and works fine for prod.

Database Cache

Why MySQL driver cache is not supported? Since SQLite3 is supported I believe MySQL is not difficult to add?

Skipped adapters tests

We have some adapters that are old and their tests are not being executed by Travis:

  • ApcCache: we could get it to run by installing apcu-bc but the tests fails
  • CouchbaseCache: it seems the extension never got enabled in Travis and PHP 7 compatibility was only added on v2.2.0 which might probably use a different API
  • MemcacheCache: lastest release of ext-memcache was in 2013-04-07
  • RiakCache: latest release of ext-riak was in 2014-06-22 (and it's not compatible with PHP 7)
  • WinCacheCache: we depend on ext-wincache and https://www.iis.net/downloads/microsoft/wincache-extension to be able to test it
  • XcacheCache: according to http://xcache.lighttpd.net it's not compatible with PHP 7
  • ZendDataCache: we obviously need Zend Data cache

So my question is: are they still relevant? If not (at least for some), shouldn't we drop the implementation and trigger deprecation notes?

If some of those are indeed needed we need to find a way to ensure that the test suite is running, otherwise we cannot guarantee their behaviour.

MemcacheCache::contains() always returns true on some machines

When I run this snippet:

$cache = new Doctrine\Common\Cache\MemcacheCache();
$memcache = new Memcache();
$memcache->pconnect('localhost', 11211);
$cache->setMemcache($memcache);
$cache->flushAll();
$cache->deleteAll();
$key = uniqid('key');
var_dump($cache->contains($key));
var_dump($cache->fetch($key));

It outputs

true
false

on certain machines, while on others it works fine. For example, on Ubuntu 16.10, contains() returns false as it should, but on Mac OS 10.10 (with Memcache 1.4.24 installed via brew), the output looks as above.

I've a bit through the code, and it seems that $flags in this line:

https://github.com/doctrine/cache/blob/master/lib/Doctrine/Common/Cache/MemcacheCache.php#L81

is int(0) in all cases. I'm having the same issue in scrutinizer's build environment, so it doesn't seem to be limited to Mac either. Not sure how to deal with this, but it makes the contains() function pretty useless

Move namespacing functionality into a "CacheNamespace" class

Would be cool if the cache namespacing feature would be available via its own class, which wraps a \Doctrine\Common\Cache\Cache, and prefixes all keys just like CacheProvider does it.

This way also classes which don't extend from CacheProvider and only implement Cache are usable with cache namespaces.

Example Usage:

<?php

use Doctrine\Common\Cache\CacheNamespace;
use Doctrine\Common\Cache\ApcCache;

$apc = new ApcCache;
$namespace = new CacheNamespace("foo", $apc);

# Namespaces the key "foo" inside the cache
$namespace->save("foo", "bar");

cache filenames are too long for windows when running on vagrant

this is related to #124 you fixed the issue on windows, but when running on vagrant the change does not solve the problem. If the host OS is Windows and guest OS (VM) is Linux, the code thinks it's running on Linux and creates very long filenames. Unfortunately there is no check to determine what the host OS is windows.

why this much entropy is needed in file names anyway ?

maybe the whole code could be simplified to limit the path/filename to 260 chars on all OSes, that would solve the problem and wouldn't require any additional check of OS

FileCache.php bug at line 140 in protected function getFilename

(($this->isRunningOnWindows && $this->directoryStringLength + 4 + strlen($id) * 2 + $this->extensionStringLength) > 259) is always false
BECAUSE
($this->isRunningOnWindows && $this->directoryStringLength + 4 + strlen($id) * 2 + $this->extensionStringLength) is boolean
AND
259 is too high for windows which cause "fopen failed to open stream: Invalid argument doctrine cache"

Original

    protected function getFilename($id)
    {
        $hash = hash('sha256', $id);

        // This ensures that the filename is unique and that there are no invalid chars in it.
        if (
            '' === $id
            || ((strlen($id) * 2 + $this->extensionStringLength) > 255)
            || (($this->isRunningOnWindows && $this->directoryStringLength + 4 + strlen($id) * 2 + $this->extensionStringLength) > 259)
        ) {
            // Most filesystems have a limit of 255 chars for each path component. On Windows the the whole path is limited
            // to 260 chars (including terminating null char). Using long UNC ("\\?\" prefix) does not work with the PHP API.
            // So if the id in hex representation would surpass the limit, we use the hash instead. The prefix prevents
            // collisions between the hash and bin2hex.
            $filename = '_' . $hash;
        } else {
            $filename = bin2hex($id);
        }

ApcuCache() not in 1.5 releases?

Is there a reason ApcuCache() which is in master is not getting included in the 1.5 releases? Would be nice to make that PHP 7 APCu support available. Cheers!

PHP 5.6 compatibility

Hi

In composer.json we can found this restriction which limits PHP to 5.5 or 7 :

    "require": {
        "php": "~5.5|~7.0"
    },

Why such restriction ?
Could it be added support for 5.6 ?

Thanks

is_writable on read-only filesystem is a non-sense

The story

I use doctrine cache through symfony and i have a read-only filesystem with the following file permission

 -r-xr-xr-x  1 www-data www-data 170434 Apr 19 11:34 folder
 -r--r--r--  1 www-data www-data 170434 Apr 19 11:34 file.ext

Issue

I don't have write permission on files and folder and i got an error in production when i need to load cache through lib/Doctrine/Common/Cache/FileCache.php.

Uncaught PHP Exception InvalidArgumentException: \"The directory \"[...]var/cache/prod/annotations\" is not writable.\" at [...]vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php line 92

In my case, all cache are created before puting file into production server, so the cache is here and don't need to be generated at runtime. No write permission is fundamentally required.

Please don't tell anyone but i fixed the issue with ugly hack on my code

Fix suggestion

Move is_writable out of constructor

I suggest to remove the "is_writable" check in the constructor of fileCache : https://github.com/doctrine/cache/blob/master/lib/Doctrine/Common/Cache/FileCache.php#L91

and to move this check to all "write" actions like it is already done in "writeFile" : https://github.com/doctrine/cache/blob/master/lib/Doctrine/Common/Cache/FileCache.php#L239

Use own implementation with RW & RO in symfony

see #157 (comment)

Cons

  • It may have a BC break on all implementation of the abstract class FileCache because they will need to check write permission if they do file modification themselves.
  • Cache object is supposed to be RW (#157 (comment))
  • Make it easy to notice file Permission issue (#157 (comment))
  • Mathematic say you cannot be absolutely sure you won't miss cache (#157 (comment))

Pro

  • Can use not writable folder to read stored cache file (this all the point of this issue :-) )

What do you say about it ?

Can you give me opinions and pro/cons you see ?

Misleading cache statistics

The default namespaceVersion (1) is always read, but never written into the cache. See:

$this->namespaceVersion = $this->doFetch($namespaceCacheKey) ?: 1;

This increments get_misses on memcache on every request.

I would propose to store the default namespaceVersion in the cache too (i think the existing behavior is not clean/logical that we only store versions >1. This makes version 1 a special case and i don't like special cases).

However, there are tests that explicitly mention that this should not happen. Should this assumption be changed and the tests refactored?

If so, i probably can submit a PR.

Thank you for your Feedback.

Feature request: Limited ArrayCache

Feature request: a limited size version of ArrayCache

Use: Similar to ArrayCache, but without risking out-of-memory in bulk or long-running script cases.

Roughly a copy of the existing ArrayCache changing doSave

    /**
     * {@inheritDoc}
     */
    protected function doSave($id, $data, $lifeTime = 0)
    {
        if (count($this->data) >= $this->cacheLimit) {
            $this->doFlush();
        }

        $this->data[$id] = [$data, $lifeTime ? time() + $lifeTime : false];

        return true;
    }

Due to ArrayCache::data being private, simply extending the ArrayCache class is not an option.

Escape colons in DoctrineNamespaceCacheKey[<cache namespace>]

Using the redis cache driver, I want to be able to use doctrine: as my namespace, as this will turn doctrine into a folder thus keeping redis browsable. However, as the colon is not escaped, this key stops working: DoctrineNamespaceCacheKey[doctrine:]

Maybe that key could be $namespace . 'DoctrineNamespaceCacheKey' instead? That would fix this error and put that key in the doctrine folder where it belongs :)

copied from doctrine/orm#6296

Impossible to override Redis serializer

Hi! Even though we have the igbinary extension installed we don't want cache entries to be serialized with igbinary. Unfortunately, even though the phpredis client we use already has the OPT_SERIALIZER set, the RedisCache class ignores that and sets it to use igbinary if it detects the extension is present. Could a method be created to manually set which serializer method we want?

Thanks!

should lifeTime have int type declaration ?

public function save($id, $data, $lifeTime = 0);

Since it is used with null in

https://github.com/doctrine/common/blob/a61bfddd39b887265117806e81cc6ca8da242fe1/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php#L200-L203

and adding a test for null lifeTime fails CouchbaseBucketCacheTest and PhpFileCacheTest

     /**
     * @dataProvider provideDataToCache
     */
    public function testLifeTimeNull($value) : void
    {
        $cache = $this->_getCacheDriver();

        // Test saving a value, checking if it exists, and fetching it back
        self::assertTrue($cache->save('key', $value, null));
        self::assertTrue($cache->contains('key'));
    }

https://travis-ci.org/serbancatalin/cache/builds/352894953

Only test is_writeable() if necessary

I'm working on getting a Symfony app running up on Google App Engine's Standard PHP environment where the filesystem is read-only. Trying to use the EasyAdminBundle which uses FileCache under the hood. To make things work, I warmup the cache before deploying so many things are effectively pre-cached in production.
The is_writeable() test in the constructor for FileCache is causing the app to fail in production even though the directory and the pre-cached file within it are already there. I wonder if it would be possible to move that test elsewhere when an attempt is actually being made to write.

MemcacheCache & Compression

Hi Doctrine community!

I don't know if I'm asking this question at the right place but I'll give a try.

We are using Doctrine & Memcache in our company and I was looking for enabling compression as it is provided by PHP (http://php.net/manual/fr/memcache.set.php).
But it seems that Doctrine\Common\Cache\MemcacheCache::doSave doesn't allow an argument to do so.

Is it a feature that would be released soon? Is it possible to fork the project and suggest it?

Thanks in advance for your help.

Couchbase support

hi Doctrine,

i'm looking for a PSR Couchbase implementation and came across a handful. of particular note is http://www.php-cache.com/en/latest/ which references Doctrine as being a Couchbase cache provider. i notice that the build does not install the extension, so tests are skipped. it appears that the adapter in this package expects an older version of the extension as well. current extension version(s) has \CouchbaseCluster and \CouchbaseBucket, or \Couchbase\Cluster and \Couchbase\Bucket instead of \Couchbase.

was wondering if i am on the right track or if i'm way off base. if i'm on to something, i was wondering if there is any interest in asserting the extension version in the existing adapter, and adding a new adapter for the more recent Couchbase extension. if so, i'd be interested in contributing.

Cache is never cleared

There's a possibility that this affects all caches (incl metadata) and not just query cache, but what i've looked at is the query cache specifically.

Clearing the query cache does not actually remove anything from the cache. instead, a new namespace is set. since there is no ttl on query cache by default (and i have not found any way to set one), these old entries will remain forever and eat up the cache space.

Tagged caching support

Goal:

I'm developing a "tagged cache" feature for RedisCache and RiakCache -- and other stores which support a datatype similar to set (PredisCache, CouchBaseCache, MongoDBCache, Sqlite3Cache).

I wanted to develop it stand-alone as an extension, unfortunately many private fields/methods make this burdensome via extensions (ex.: RedisCache::getNamespacedId, PredisCache::$client, RiakCache::$bucket).

I could either contribute my work so far if this feature would be of interest to the core deciders ...if not I would like to continue my stand-alone development but I would ask for support in opening up some new extension points (making some methods protected).

Concept:

  • Save an item
  • Supply a list of tags associated with the item
  • Fetch or delete lists of items based on their tags
    • all items which have any of the these tags
    • all items which have all of the tags

Redis implementation example:

In Redis / Predis (and Riak) you can use the set datatype for this purpose:

$cache->save($id, $value, $lifetime, $tags);

/* or */

$cache->save($id, $value, $lifetime);
$cache->tag($tags);
SET item_1_id item_1_value

SADD tag_value_1 item_1_id
/* ... */
SADD tag_value_n item_1_id

Retrieval would be similar:

$cache->fetchByTags($tags);
SINTER tag_value_1 ... tag_value_n
MGET item_1_id ... item_n_id

Cache component generates too long filename

I have Ubuntu 14.04.2 LTS with encrypted filesystem. It's known limitation, but I think Doctrine should work on such configurations.

As a result doctrine generates cache on each request.

rename(/data/www/sf2-app/app/cache/dev/annotations/3a/swaplxj6AI,/data/www/sf2-app/app/cache/dev/annotations/3a/5b5b435d4564737465725c42756e646c655c41707042756e646c655c456e746974795c557365725c557365722466697273744e616d65405b416e6e6f745d5d5b315d.doctrinecache.data): File name too long
Context: { "type":2,"file": "/data/www/sf2-app/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php", "line":254,"level":28928,"scream":true}

Windows-PHP bug on path length

I always have the issue on Windows 7 pro using the doctrine/cache version v1.5.4. and PHP 5.4, I was obliged to decrease the value to 254 to work fine.

Insufficient namespace isolation when flushing Redis-based cache

We have a Redis that is shared between different applications. Normally, the applications don't step on each other's feet because they all use different namespaces. However, when flushing the cache, this namespace seems to be ignored completely, so that it flushes the cache for all applications. In some cases that's a really bad thing, because computing the cached values takes considerable amounts of time.

Notes here:

  • The observations were made using 1.6.2. Checking the release notes doesn't indicate any change though, so the later releases are probably affected, too.
  • I think that not only the Redis implementation is affected. flushAll() doesn't provide any hint what to flush, so backend can only retrieve the namespace themselves or delete the whole cache.
  • I'll try to implement a fix for the Redis part and post updates when I have further info.

ChainCache save value with infinite lifetime when propagate to fastest cache

In case of item found in the chain of cache, a propagation of the value is made backward.
Those save are made without any TTL :

// We populate all the previous cache layers (that are assumed to be faster)
for ($subKey = $key - 1; $subKey >= 0; $subKey--) {
$this->cacheProviders[$subKey]->doSave($id, $value);
}

It lead to have infinite lifetime on those fastest cache ; and so many issue in production.

Here a test case to reproduce:

    public function testFetchPropagateToFastestCacheWithTTL()
    {
        $cache1 = new ArrayCache();
        $cache2 = new ArrayCache();

        $cache2->save('bar', 'value', 1);

        $chainCache = new ChainCache([$cache1, $cache2]);

        self::assertFalse($cache1->contains('bar'));

        $result = $chainCache->fetch('bar');

        self::assertEquals('value', $result);
        self::assertTrue($cache1->contains('bar'));

        sleep(2);

        self::assertFalse($cache2->contains('bar'));
        self::assertFalse($cache1->contains('bar'));
        self::assertFalse($chainCache->contains('bar'));
    }

2 proposals that i see:

  • Maybe we could have a short default ttl inside ChainCache that will be used in case of chain propagation?
  • Get the remained ttl and propagate with this value ? (currently ttl is not exposed)

Filenames are too long for windows

Caching was not working for me properly on my computer so I tried to dig up why. Turns out that this rename call often fails with Warning rename(...) Invalid argument. Of course the error was suppressed by the @ operator so it took a while to find. The warning happens when the path is too long (probably 256 characters is a limit).

I tried to upgrade to dev-master, it didn't help.

Make protected CacheProvider::getNamespacedId()

Hi,
I see a lot native functions of some caches are not provided.
For example in Redis there is no possibility to work with hashed, lists, sets, no possibility to increment, decrement values. In this case, extending RedisCache can help.
And it will be great, that for all this native functions, we can use your formatted namespacedId.

What do you think?

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,
                    )
                );
            }

The CacheProvider::fetchMultiple method throw a warning level error

The CacheProvider::fetchMultiple method throw a warning when use memcached driver:

<b>Warning</b>:  array_key_exists() expects parameter 2 to be array, boolean given in <b>./vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php</b> on line <b>98</b><br />

the CacheProvider::fetchMultiple called CacheProvider::doFetchMultiple on line 92, mamached driver method MemcachedCache::doFetchMultiple is override CacheProvider::doFetchMultiple, called Memcached::getMulti return false when items keys is not found, CacheProvider file on line 98 array_key_exists($namespacedKey, $items), $items is false, so warning has been throw.

change CacheProvider::fetchMultiple on line 92:

$items = (array) $this->doFetchMultiple($namespacedKeys);

Test suite attempts to delete `/tmp`

Tested under Ubuntu 16.10:

Time: 17.67 seconds, Memory: 18.00MB

There were 4 errors:

1) Doctrine\Tests\Common\Cache\FilesystemCacheTest::testWindowsPathLengthLimitIsCorrectlyHandled with data set #0 (257, false)
UnexpectedValueException: RecursiveDirectoryIterator::__construct(/tmp/systemd-private-c5857b05b52947c8a8b530fa708ce33d-colord.service-Ke0Ba1): failed to open dir: Permission denied

cache/tests/Doctrine/Tests/Common/Cache/BaseFileCacheTest.php:27
/usr/local/share/poser/vendor/phpunit/phpunit/src/TextUI/Command.php:149
/usr/local/share/poser/vendor/phpunit/phpunit/src/TextUI/Command.php:100

2) Doctrine\Tests\Common\Cache\FilesystemCacheTest::testWindowsPathLengthLimitIsCorrectlyHandled with data set #2 (259, true)
UnexpectedValueException: RecursiveDirectoryIterator::__construct(/tmp/systemd-private-c5857b05b52947c8a8b530fa708ce33d-colord.service-Ke0Ba1): failed to open dir: Permission denied

cache/tests/Doctrine/Tests/Common/Cache/BaseFileCacheTest.php:27
/usr/local/share/poser/vendor/phpunit/phpunit/src/TextUI/Command.php:149
/usr/local/share/poser/vendor/phpunit/phpunit/src/TextUI/Command.php:100

3) Doctrine\Tests\Common\Cache\PhpFileCacheTest::testWindowsPathLengthLimitIsCorrectlyHandled with data set #0 (257, false)
UnexpectedValueException: RecursiveDirectoryIterator::__construct(/tmp/systemd-private-c5857b05b52947c8a8b530fa708ce33d-colord.service-Ke0Ba1): failed to open dir: Permission denied

cache/tests/Doctrine/Tests/Common/Cache/BaseFileCacheTest.php:27
/usr/local/share/poser/vendor/phpunit/phpunit/src/TextUI/Command.php:149
/usr/local/share/poser/vendor/phpunit/phpunit/src/TextUI/Command.php:100

4) Doctrine\Tests\Common\Cache\PhpFileCacheTest::testWindowsPathLengthLimitIsCorrectlyHandled with data set #2 (259, true)
UnexpectedValueException: RecursiveDirectoryIterator::__construct(/tmp/systemd-private-c5857b05b52947c8a8b530fa708ce33d-colord.service-Ke0Ba1): failed to open dir: Permission denied

cache/tests/Doctrine/Tests/Common/Cache/BaseFileCacheTest.php:27
/usr/local/share/poser/vendor/phpunit/phpunit/src/TextUI/Command.php:149
/usr/local/share/poser/vendor/phpunit/phpunit/src/TextUI/Command.php:100

I've debugged a little and the problems comes from

https://github.com/doctrine/cache/blob/master/tests/Doctrine/Tests/Common/Cache/BaseFileCacheTest.php#L117

where (at least on Linux) $this->directory is set to /tmp.

When the test has finished, the tearDown method tries to recursively delete this directory and everything in it:

https://github.com/doctrine/cache/blob/master/tests/Doctrine/Tests/Common/Cache/BaseFileCacheTest.php#L25

PredisCache doSaveMultiple with TTL sends multiple separate calls instead of single

We had case of saving 2k entries with multi save, which took 30-ish seconds (round trip time?). This was used as quick&dirty workaround. Maybe this can be of use after some tweaking.

protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
{
    if ($lifetime) {
        $success = true;

        $responses = $this->client->pipeline(function (Pipeline $pipe) use ($keysAndValues, $lifetime) {
            // Keys have lifetime, use SETEX for each of them
            foreach ($keysAndValues as $key => $value) {
                $pipe->setex($key, $lifetime, serialize($value));
            }
        });

        foreach ($responses as $response) {
            if ((string)$response != 'OK') {
                $success = false;
            }
        }

        return $success;
    }

    // No lifetime, use MSET
    $response = $this->client->mset(array_map(function ($value) {
        return serialize($value);
    }, $keysAndValues));

    return (string) $response == 'OK';
}

Corrected `FileCache` notices caused by custom error handlers

Hi.
I get a lot of notices in my error log from file vendor/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php

I saw yours note

note: error suppression is still faster than `file_exists`, `is_file` and `is_readable`

But may be you can add file_exists check optional?

Missing docs

This library would be infinitely more valuable if there were even rudimentary documentation demonstrating basic usage.

PredisCache "invalid bulk length" error

Predis version: 1.1.1
Redis server version: 3.0.7

I keep getting the error from the Redis server when attempting to retrieve a cached value:

ERR Protocol error: invalid bulk length


What the data looks like after hydrating and passing to the CacheProvider:

array(1) {
  ["SELECT t0_.id AS id_0 FROM test t0_ WHERE t0_.id = ?-a:1:{i:0;i:1;}-a:1:{i:0;s:7:"integer";}"]=>
  array(1) {
    [0]=>
    array(1) {
      ["id_0"]=>
      string(1) "1"
    }
  }
}

Cache setup

$config = Setup::createConfiguration();
$redis_cache = new PredisCache(new PredisClient('connection_string_here'));
$config->setResultCacheImpl($redis_cache);
$entity_manager = EntityManager::create($db_params, $config);

TestEntity

class TestEntity
{
    /**
     * @var int
     */
    private $id;

    /**
     * Gets the id.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Sets the id.
     *
     * @param int $id
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }
}

Test Entity Mapping

$builder = new ClassMetadataBuilder($metadata);
$builder->setTable('test');

$builder
    ->createField('id', Type::INTEGER)
    ->nullable(false)
    ->unique(true)
    ->option('unsigned', true)
    ->makePrimaryKey()
    ->build();

$metadata->setIdGenerator(new AssignedGenerator());
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO);

$metadata->markReadOnly();

Example fetch

$test = $entity_manager->createQueryBuilder()
    ->select('test')
    ->from(TestEntity::class, 'test')
    ->where('test.id = :id')
    ->setParameter('id', 1, Type::INTEGER)
    ->getQuery()
    ->setResultCacheId('test_id')
    ->getSingleResult();

My best guess is that calling PredisClient::set($key, $data) where $data is a nested array is causing an issue since the data isn't serialized. Or I've just somehow messed up my setup/implementation.

Let me know if there's any more information I can provide!

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.