https://github.com/eghojansu/cache-helper
PHP Cache helper
https://github.com/eghojansu/cache-helper
apc apcu cache filecache memcached php redis wincache xcache
Last synced: 2 months ago
JSON representation
PHP Cache helper
- Host: GitHub
- URL: https://github.com/eghojansu/cache-helper
- Owner: eghojansu
- License: mit
- Created: 2018-02-19T06:58:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-22T05:18:43.000Z (over 7 years ago)
- Last Synced: 2025-02-09T12:43:09.908Z (4 months ago)
- Topics: apc, apcu, cache, filecache, memcached, php, redis, wincache, xcache
- Language: PHP
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PHP Cache-Helper
================PHP Caching helper. It supports several cache-engine.
- Apc;
- Apcu;
- Memcached;
- Redis;
- Wincache;
- Xcache;
- FileCache (as an alternative or fallback).Background
----------The original code taken from [Fatfree][1] Cache class. Because the original code was very complex for me, i decide to make this repo.
Installation
------------`composer require eghojansu/cache-helper:dev-master`
Usage
-----Main Cache class will proxy method call to the driver.
To use a driver you can pass simple dsn format to first constructor.```php
get('foo');
if ($cached) {
list( $data ) = $cached;
} else {
$data = 'foo';
$cache->set('foo', $data);
}echo $data;
```
DSN Format
----------```
+-----------+----------------------------------------------------+------------------------+
| Driver | DSN | ~ |
+-----------+----------------------------------------------------+------------------------+
| Apc | apc | |
| Apcu | apcu | |
| Memcached | memcached=host[:port];host2[:port];...hostn[:port] | |
| Redis | redis=host[:port[:db]] | |
| Wincache | wincache | |
| Xcache | xcache | |
| Filecache | folder=/path/to/cache/dir/ | Require trailing slash |
| NoCache | (empty string) | To disable cache |
+-----------+----------------------------------------------------+------------------------+
```If dsn supplied and no match based on above rule, FileCache will be used.
Credits
-------- [Fatfree Framework Author and Contributors][1]
[1]: http://fatfreeframework.com