From 30b8b6f63bea581f5762bd59c513c514ea2de7f4 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 1 Oct 2014 00:07:55 +0200 Subject: [PATCH] Adding composer.json and Readme to Cache Cache will be exported to another repo --- composer.json | 3 ++- src/Cache/README.md | 57 +++++++++++++++++++++++++++++++++++++++++ src/Cache/composer.json | 20 +++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/Cache/README.md create mode 100644 src/Cache/composer.json diff --git a/composer.json b/composer.json index 0c08fd04fac..c7ecc17afba 100644 --- a/composer.json +++ b/composer.json @@ -51,6 +51,7 @@ "cakephp/validation": "self.version", "cakephp/utility": "self.version", "cakephp/core": "self.version", - "cakephp/datasource": "self.version" + "cakephp/datasource": "self.version", + "cakephp/cache": "self.version" } } diff --git a/src/Cache/README.md b/src/Cache/README.md new file mode 100644 index 00000000000..37b475a683a --- /dev/null +++ b/src/Cache/README.md @@ -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) + + diff --git a/src/Cache/composer.json b/src/Cache/composer.json new file mode 100644 index 00000000000..30b67818125 --- /dev/null +++ b/src/Cache/composer.json @@ -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" +}