Browse Source

Merge pull request #4776 from cakephp/3.0-extract-cache

Adding composer.json and Readme to Cache
Mark Story 11 years ago
parent
commit
fc7955329b
3 changed files with 79 additions and 1 deletions
  1. 2 1
      composer.json
  2. 57 0
      src/Cache/README.md
  3. 20 0
      src/Cache/composer.json

+ 2 - 1
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"
 	}
 }

+ 57 - 0
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 - 0
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"
+}