Skip to content

Commit

Permalink
Adding composer.json and Readme to Cache
Browse files Browse the repository at this point in the history
Cache will be exported to another repo
  • Loading branch information
lorenzo committed Sep 30, 2014
1 parent 9ecf121 commit 30b8b6f
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -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"
}
}
57 changes: 57 additions & 0 deletions 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)


20 changes: 20 additions & 0 deletions 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"
}

0 comments on commit 30b8b6f

Please sign in to comment.