Download the PHP package sugiphp/cache without Composer
On this page you can find all versions of the php package sugiphp/cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sugiphp/cache
More information about sugiphp/cache
Files in sugiphp/cache
Informations about the package cache
Cache
SugiPHP cache component provides a simple and unified API for several caching systems like APC, Memcached and file based cache.
One of the most important features of the caching systems is invalidating items after a specified period of time. This will give you the ability to cache some time consuming queries like the total number of adverts in your site, and not worry about if some advert is deleted or some adverts are posted, but instead set a time after which that number is invalidated and needs to be refreshed.
One other feature is that no matter if the store is actually running (caching items) or not it will not produce any errors or exceptions. Instead it will return NULL on any get requests. In the above example this means that your code will be fooled to count adverts every time, maybe slowing down performance, but still working. Your code will still work on some development or testing environments where no cache is available nor is needed.
Installation
Settings
-
Using APC (APCu) as a cache:
-
Using file-based cache:
-
Using Memcached:
- NullStore and ArrayStore
Those two classes are not real cache storages, but they are usefull on development environments and for unit tests. ArrayStore caches values only for a lifetime of the script, and thus the expiration time is not implemented. All store values will be flushed after the script is over.
NullStore is actually a fake store. It is used to check your code is operational even if there is no cache storages available or if there is a problem with existing ones, e.g. no space left on the server or there is no connection with Memcached. Other use is when you wish your code to work without any caching for a while. Especially usefull on development when any caching mechanism can be a disadvantage.
Usage
Caching is done by setting a key-value pairs in a store.