Title
PHP Cache - PHP-Cache Documentation
Go Home
Category
Description
None
Address
Phone Number
+1 609-831-2326 (US) | Message me
Site Icon
PHP Cache - PHP-Cache Documentation
Page Views
0
Share
Update Time
2022-08-17 04:34:20

"I love PHP Cache - PHP-Cache Documentation"

www.php-cache.com VS www.gqak.com

2022-08-17 04:34:20

PHP-Cache Documentation PHP Cache PHP Cache Cache pool implementations Installation Features Framework integration Organisation overview Contact Doctrine bridge Hierarchy Introduction Namespace Implementing cache pools Adapter common Hierarchy Integration tests Symfony Adapter bundle Cache bundle PHP-Cache Documentation Docs » PHP Cache PHP Cache¶The PHP Cache organization is dedicated to providing solid, powerful, flexible, and lightweight caching libraries for PHPprojects. All of the adapters we have created are PSR-6 and PSR-16 compliant. If you are a library implementer, we even have a repository of tests to help you meet the PSR specification.Below you will find information about what features our libraries offer, and what adapters we have. You can also find outframework integration libraries.If you are new to PSR-6 caching you may want to have a look at our introduction.Note: The PHP-cache organization has been pushing the limits of caching for many years. But currently we fall behind the quicker and better maintained Symfony Cache.Cache pool implementations¶There are plenty of adapters in this organization. Each of them lives in a different repository. Splitting them up in multiplepackages complies with the Common reuse principle and makes it easier for the developer to follow the changes of a specificadapter. Each adapter has it own features. The table below lists all our adapters and their features. AdapterTaggingHierarchy*BadgesApcYesNo ApcuYesNo ArrayYesNo Couchbase 1.x (via Doctrine)YesNoFilesystem (via Flysystem)YesNo IlluminateYesNo MemcacheYesNo MemcachedYesYes MongoDBYesNo PredisYesYes RedisYesYes Riak (via Doctrine)YesNoSQLite3 (via Doctrine)YesNoVoidYesYes WinCache (via Doctrine)YesNoXcache (via Doctrine)YesNoZendData (via Doctrine)YesNoChainYes DoctrineYesNo * Hierarchy store lots of extra items in cache that are never actively removed. Some implementations of cache storages like Redis and Memcache will automatically remove these items when they're stale or no longer used. That is why hierarchywill work better on such cache storages.Chain adapter¶We also have a chain adapter where you can chain multiple pool together. It is great if you have a fast storage with limited memory and a slower storage with loads of memory. Doctrine adapter¶The doctrine adapter is a PSR-6 adapter that wraps a Doctrine\Common\Cache\Cache object. With this adapter you can use storages like Riak and WinCache which currently do not have any PHP Cache adapters. Installation¶Use composer to install any of the adapters above. Some adapters may require configuration before they can be used. Refer to the adapter's Github page to see how they are configured. You could also use the Symfony AdapterBundle to configure the adapters. composer require cache/[any]-adapterYou can also install all of the adapters with the cache/cachecomposer require cache/cacheRequirements¶Unless other is specified, all adapters support PHP version ^5.5 and ^7.0. Most adapters do also have requirementson PHP extension. Like the Redis adapter requires ext-redis. Features¶Tagging¶Tags is used to control the invalidation of items. $item = $pool->getItem('tobias');$item->set('value')->setTags(['tag0', 'tag1'])$pool->save($item);$item = $pool->getItem('aaron');$item->set('value')->setTags(['tag0']);$pool->save($item);// Remove everything tagged with 'tag1'$pool->invalidateTags(['tag1']);$pool->getItem('tobias')->isHit(); // false$pool->getItem('aaron')->isHit(); // true$item = $pool->getItem('aaron');echo $item->getPreviousTags(); // array('tag0')// No tags will be saved again. This is the same as saving// an item with no tags.$pool->save($item);Hierarchy¶Think of a hierarchy like a file system. If you remove a folder "Foo", all items and folders in "Foo" will also be removed. A hierarchical cache key must start with a pipe ("|").$pool->hasItem('|users|4711|followers|12|likes'); // True$pool->deleteItem('|users|4711|followers');$pool->hasItem('|users|4711|followers|12|likes'); // FalseNamespace¶Namespace can be used to separate the storage of different systems in the cache. This allows different sections to be clearedon an individual level, while also preventing overlapping keys.$pool = new ArrayCachePool();$namespaceFoo = new NamespacedCachePool($pool, 'foo');$item = $namespaceFoo->getItem('key')->set('value');$namespaceFoo->save($item);$namespaceBar = new NamespacedCachePool($pool, 'bar');$namespaceBar->hasItem('key'); // False$item = $namespaceBar->getItem('key')->set('value');$namespaceBar->save($item);$namespaceBar->hasItem('key'); // True$namespaceFoo->deleteItem('key');$namespaceFoo->hasItem('key'); // False$namespaceBar->hasItem('key'); // True$namespaceFoo->clear();$namespaceBar->hasItem('key'); // TruePrefix¶A prefix will help you to avoid cache key collisions. The prefixed cache pool supports any PSR-6 cache implementations. The PrefixedCachePool differs from the NamespacedCachePool in two aspects: 1) You could still have conflicts if one cache key includes the prefix2) When clearing the cache all cache items will be cleared, not only the prefixed ones. $pool = new ArrayCachePool();$prefixedFoo = new PrefixedCachePool($pool, 'foo');$item = $prefixedFoo->getItem('key')->set('value');$prefixedFoo->save($item);$pool->hasItem('key'); // False$item = $pool->getItem('key')->set('value');$pool->save($item);$pool->hasItem('key'); // True$prefixedFoo->deleteItem('key');$prefixedFoo->hasItem('key'); // False$pool->hasItem('key'); // True$prefixedFoo->clear();$pool->hasItem('key'); // FalseFramework integration¶Symfony¶There are two Symfony bundles; AdapterBundle and CacheBundle. The AdapterBundle is used to configure and register a PSR-6 cache pool as a Symfony service. The CacheBundle is used to integrate any PSR-6 cache service with the framework. It supports session cache, doctrine cache, validation cache and many more. We would LOVE to see integration with Zend, Laravel, Yii, Cake, and even Code Igniter. If you would like to contribute, we would love to see your code.Organisation overview¶Excluding our adapters, we have the following packagesNameDescriptionBadgesCacheBase Cache Repository. Contains all adapters. AdapterBundleBundle to register adapters to services. Adapter commonThe AbstractCachePool and CacheItem live here. CacheBundleBundle to integrate any PSR-6 service with theSymfony framework. Doctrine bridgeA bridge from PSR-6 to DoctrineCache EncryptionEncrypt data you store Hierarchical cacheA trait and interface to support cache hierachy Integration testsUsed to verify any PSR-6 implementation Namespaced cachePool to support a namespace Prefixed cachePool to support a prefix Session handlerImplementation of \SessionHandlerInterface Simple Cache BridgeBridge from PSR-6 to PSR-16 SimpleCache Taggable cacheDecorator to make any PSR-6 cache taggable Tag interopInterfaces to support cache tagging. (Soon PSR) Contact¶ We would love to hear form you. Ping us on twitter @aequasi and @tobiasnyholm. You could also join us on Gitter. Next © 2015 PHP Cache Team Built with MkDocs using a theme provided by Read the Docs. Next »