doctrine / cache Goto Github PK
View Code? Open in Web Editor NEWDoctrine Cache component
Home Page: https://www.doctrine-project.org/projects/cache.html
License: MIT License
Doctrine Cache component
Home Page: https://www.doctrine-project.org/projects/cache.html
License: MIT License
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
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:
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 :
cache/lib/Doctrine/Common/Cache/ChainCache.php
Lines 50 to 53 in 2b0e130
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:
As mentioned on doctrine/orm#4602 and doctrine/orm#1424 Memcached has issues with keys that contains spaces and the ORM generates some of this keys for L2C.
However, as pointed by @Ocramius, the fix should be made on this package since only memcached has this issue.
File:
lib/Doctrine/Common/Cache/RiakCache.php
Message:
Line 26: Name "object" that is reserved for future use (does not cause an error in PHP 7) used as a use statement alias Riak\Object
More information
List of other reserved words
Why MySQL driver cache is not supported? Since SQLite3 is supported I believe MySQL is not difficult to add?
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.
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).
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
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:
flushAll()
doesn't provide any hint what to flush, so backend can only retrieve the namespace themselves or delete the whole cache.When I clear the cache using php bin/console doctrine:cache:clear-metadata --env=prod;
or php bin/console doctrine:cache:clear-query --env=prod;
I receive the error Call to undefined function Doctrine\Common\Cache\apcu_fetch()
.
The function apcu_fetch()
is called from https://github.com/doctrine/cache/blob/master/lib/Doctrine/Common/Cache/ApcuCache.php but it doesn't exist in the file, neither in the project...
Do I miss something ?
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.
Related to doctrine/mongodb#239: in order to currently use MongoDBCache ext-mongo
is required. This extension has been replaced by ext-mongodb on PHP 7.
Effectively this means that MongoDBCache can currently not be used on PHP 7.
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.
This is a missing test in our suite, but basically, PhpFileCache
will fail to store/load a [new SomeObject]
due to how var_export()
works
RiakCache currently depends on the riak extension which hasn't been updated in years and won't build on php7.0 or 7.1.
+1 to use @FabioBatSilva's https://github.com/php-riak/riak-client
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
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.
Given that doctrine voted -1, I think this is a valid question.
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!
Invalid code here
https://github.com/doctrine/cache/blob/master/lib/Doctrine/Common/Cache/FileCache.php#L223
I dont understand why
false === @mkdir($path, 0777 & (~$this->umask), true) && !is_dir($path)
I think valid will be
!is_dir($path) && false === @mkdir($path, 0777 & (~$this->umask), true)
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);
cache/lib/Doctrine/Common/Cache/Cache.php
Line 62 in e3fcea0
Since it is used with null in
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'));
}
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
(($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);
}
We have some adapters that are old and their tests are not being executed by Travis:
apcu-bc
but the tests failsv2.2.0
which might probably use a different APIext-memcache
was in 2013-04-07ext-riak
was in 2014-06-22 (and it's not compatible with PHP 7)ext-wincache
and https://www.iis.net/downloads/microsoft/wincache-extension to be able to test itSo 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.
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.
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.
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.
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)
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?
PSR-6 have been approved recently. Any plans on updating the cache libraries?
PSR-6 covers the following interfaces as single one
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,
)
);
}
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");
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}
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?
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';
}
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?
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.
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
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
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
see #157 (comment)
Can you give me opinions and pro/cons you see ?
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.
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
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!
The current implementation of MemcachedCache::doContains return true
if the stored value is false
and there is any kind of error code different from RES_NOTFOUND.
If the error code is something like RES_NOTSTORED, RES_SOME_ERRORS or many others then doContains
should return false
.
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.
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
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!
doctrine/common#828
I use PostgreSql. And use type bytea
.
If i cache bytea
resource (see note http://php.net/manual/en/ref.pdo-pgsql.connection.php).
I have cached string 0
.
I think possible cache resource as string with stream_get_contents.
You may need to add in the documentation that the resources are not cached. Because such information is in the documentation I have not found.
Correct me if I'm wrong.
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
This library would be infinitely more valuable if there were even rudimentary documentation demonstrating basic usage.
The default namespaceVersion (1) is always read, but never written into the cache. See:
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.