Download the PHP package christianklisch/phpcache without Composer
On this page you can find all versions of the php package christianklisch/phpcache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download christianklisch/phpcache
More information about christianklisch/phpcache
Files in christianklisch/phpcache
Package phpcache
Short Description A simple PHP caching class
License Apache 2.0
Homepage https://github.com/christianklisch/phpcache
Informations about the package phpcache
PHPCache v. 0.1.2
PHPCache is a simple file based object cache, caching big or complex calculated data in filesystem.
Use it for:
- Increasing speed of web application
- Caching result objects from complex calculations
- Caching results from complex database queries
- Caching function calls
- Cache primitive data types, own objects, function results
Features:
- Define caching time in seconds, cache directory
- Can be used with every variable / data (except. templates)
- Load data from cache or determine new data
- Clear caching directory
- Garbage collector
Installation
You can either install the script manually using the require
method:
or use the composer:
This is currently the first release of PHPCache, so in this example you'll be able to update your script with any updates made to PHPCache.
Deploying
Include the script in your project either with Composer or via the manual require
method and create a new instance of the class, using the appropriate parameters if needed:
Possible parameters include:
Primitive data type
Then cache an primitive data type with:
This will cache the string of the first parameter into a file named by second parameter. Use the second parameter setting key for primitive data types.
Object data type
Cache an object data type with:
This will cache the object in the first parameter into a file named by second parameter. Use the second parameter setting key as filename for object cache.
Object data type with automatic ID-getter
Define for each object type the id-key/primary key remove second id-parameter:
Now the objects id is automatically determined by PHPCache logic. Caching configuration is
Check for cached data
Check with the given key if data is cached. Can be used to call a new cacheVal().
Cache whole function calls
Like the value-caching you can cache results of complex logical function calls. The defined function will only be called in case of absence cached function results.
Please don't use function parametes. Submit your variables via the use()-keyword. It is important using one parameter named 'key' for caching. The name and count of other parameters is not important. Write the call of your complex logic inside the anonymous function. This code will be called, if your key isn't found in cache.
Delete old cached data
Delete old cached data in caching directory with:
Garbage Collector is not called automatically.
Clear caching directory
Delete all cached data in caching directory with:
Contributors
- Christian Klisch http://www.christian-klisch.de
Copyright and license
Copyright 2014 Christian Klisch, released under the Apache license.