Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding composer.json and Readme to Cache
Cache will be exported to another repo
- Loading branch information
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# CakePHP Caching Library | ||
|
||
The Cache library provides a `Cache` service locator for interfacing with multiple caching backends using | ||
a simple to use interface. | ||
|
||
The caching backends supported are: | ||
|
||
* Files | ||
* APC | ||
* Memcached | ||
* Redis | ||
* Wincache | ||
* Xcache | ||
|
||
## Usage | ||
|
||
Caching engines need to be configured with the `Cache::config()` method. | ||
|
||
```php | ||
use Cake\Cache\Cache; | ||
|
||
// Using a short name | ||
Cache::config('default', array( | ||
'className' => 'File', | ||
'duration' => '+1 hours', | ||
'path' => sys_get_tmp_dir(), | ||
'prefix' => 'my_app_' | ||
)); | ||
|
||
// Using a fully namespaced name. | ||
Cache::config('long', array( | ||
'className' => 'Cake\Cache\Engine\ApcEngine', | ||
'duration' => '+1 week', | ||
'prefix' => 'my_app_' | ||
)); | ||
|
||
// Using a constructed object. | ||
$object = new FileEngine($config); | ||
Cache::config('other', $object); | ||
``` | ||
|
||
You can now read a write from the cache: | ||
|
||
```php | ||
$data = Cache::remember('my_cache_key', function () { | ||
return Service::expesiveCall(); | ||
}); | ||
``` | ||
|
||
The code above will try to look for data stored in cache under the `my_cache_key`, if not found | ||
the callback will be executed and the returned data will be cached for future calls. | ||
|
||
## Documentation | ||
|
||
Please make sure you check the [official documentation](http://book.cakephp.org/3.0/en/core-libraries/caching.html) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "cakephp/cache", | ||
"description": "Easy to use Caching library with support for multiple caching backends", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "CakePHP Community", | ||
"homepage": "http://cakephp.org" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Cake\\Cache\\": "." | ||
} | ||
}, | ||
"require": { | ||
"cakephp/core": "dev-master" | ||
}, | ||
"minimum-stability": "beta" | ||
} |