kozz / yii-doctrine-cache
Doctrine Cache Factory for Yii 1
Installs: 5 003
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/kozz/yii-doctrine-cache
This package is not auto-updated.
Last update: 2025-10-25 21:48:47 UTC
README
Proxy for Doctrine Cache in Yii
When to use
YiiDoctrineCache implements Doctrine\Common\Cache\Cache interface
so it's fully compatible with all libraries that are requiring Doctrine Cache such as:
- Doctrine Annotation Reader
- Symfony Validator
- JMS Serializer
How does it works
YiiDoctrineCache loads the most suitable Doctrine Cache Implementation
in dependency of Yii Cache configuration:
Doctrine\Common\Cache\MemcachedCacheDoctrine\Common\Cache\MemcacheCacheDoctrine\Common\Cache\ArrayCache
Advantages
YiiDoctrineCache uses Proxy design pattern under the hood
so you always have the same instance of Cache every time you call new YiiDoctrineCache()
even if Doctrine's ArrayCache selected
//SomeFile.php use Kozz\Yii1\Cache\YiiDoctrineCache; $cache = new YiiDoctrineCache(); $cache->save('id', 'value'); //SomeOtherFile.php use Kozz\Yii1\Cache\YiiDoctrineCache; $cache = new YiiDoctrineCache(); $cache->fetch('id'); // 'value'
Reference
Methods
fetch($id) - Fetches an entry from the cache
contains($id) - Test if an entry exists in the cache
save($id, $data, $lifeTime = false) - Puts data into the cache
delete($id) - Deletes a cache entry