-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Max
committed
Mar 17, 2016
1 parent
18d52f1
commit 1f788c0
Showing
3 changed files
with
143 additions
and
22 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
{ | ||
"name": "mindy/cache", | ||
"homepage": "https://github.com/studio107/Mindy_Cache", | ||
"license": "MIT", | ||
"version": "0.2", | ||
"autoload": { | ||
"psr-4": { | ||
"Mindy\\Cache\\": "src/Mindy/Cache" | ||
} | ||
}, | ||
"require": { | ||
"php": ">=5.4" | ||
}, | ||
"require-dev": { | ||
"satooshi/php-coveralls": "dev-master" | ||
"name": "mindy/cache", | ||
"homepage": "https://github.com/studio107/Mindy_Cache", | ||
"license": "BSD", | ||
"version": "1.0", | ||
"autoload": { | ||
"psr-4": { | ||
"Mindy\\Cache\\": "src/Mindy/Cache" | ||
} | ||
}, | ||
"require": { | ||
"php": ">=5.4" | ||
}, | ||
"require-dev": { | ||
"satooshi/php-coveralls": "dev-master" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Maxim Falaleev", | ||
"email": "max@studio107.ru", | ||
"homepage": "http://studio107.ru", | ||
"role": "Developer" | ||
}, | ||
"authors": [{ | ||
"name": "Alex Gordeev", | ||
"email": "alex@studio107.ru", | ||
"homepage": "http://studio107.ru", | ||
"role": "Developer" | ||
}], | ||
"support": { | ||
"issues": "https://github.com/studio107/Mindy_Cache/issues?state=open" | ||
{ | ||
"name": "Alex Gordeev", | ||
"email": "alex@studio107.ru", | ||
"homepage": "http://studio107.ru", | ||
"role": "Developer" | ||
} | ||
], | ||
"support": { | ||
"issues": "https://github.com/studio107/Mindy_Cache/issues?state=open" | ||
} | ||
} |
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,72 @@ | ||
<?php | ||
|
||
namespace Mindy\Cache; | ||
|
||
/** | ||
* ICache is the interface that must be implemented by cache components. | ||
* | ||
* This interface must be implemented by classes supporting caching feature. | ||
* | ||
* @author Qiang Xue <qiang.xue@gmail.com> | ||
* @package Mindy\Base | ||
* @since 1.0 | ||
*/ | ||
interface ICache | ||
{ | ||
/** | ||
* Retrieves a value from cache with a specified key. | ||
* @param string $id a key identifying the cached value | ||
* @return mixed the value stored in cache, false if the value is not in the cache or expired. | ||
*/ | ||
public function get($id); | ||
|
||
/** | ||
* Retrieves multiple values from cache with the specified keys. | ||
* Some caches (such as memcache, apc) allow retrieving multiple cached values at one time, | ||
* which may improve the performance since it reduces the communication cost. | ||
* In case a cache doesn't support this feature natively, it will be simulated by this method. | ||
* @param array $ids list of keys identifying the cached values | ||
* @return array list of cached values corresponding to the specified keys. The array | ||
* is returned in terms of (key,value) pairs. | ||
* If a value is not cached or expired, the corresponding array value will be false. | ||
*/ | ||
public function mget($ids); | ||
|
||
/** | ||
* Stores a value identified by a key into cache. | ||
* If the cache already contains such a key, the existing value and | ||
* expiration time will be replaced with the new ones. | ||
* | ||
* @param string $id the key identifying the value to be cached | ||
* @param mixed $value the value to be cached | ||
* @param integer $expire the number of seconds in which the cached value will expire. 0 means never expire. | ||
* @param ICacheDependency $dependency dependency of the cached item. If the dependency changes, the item is labelled invalid. | ||
* @return boolean true if the value is successfully stored into cache, false otherwise | ||
*/ | ||
public function set($id, $value, $expire = 0, $dependency = null); | ||
|
||
/** | ||
* Stores a value identified by a key into cache if the cache does not contain this key. | ||
* Nothing will be done if the cache already contains the key. | ||
* @param string $id the key identifying the value to be cached | ||
* @param mixed $value the value to be cached | ||
* @param integer $expire the number of seconds in which the cached value will expire. 0 means never expire. | ||
* @param ICacheDependency $dependency dependency of the cached item. If the dependency changes, the item is labelled invalid. | ||
* @return boolean true if the value is successfully stored into cache, false otherwise | ||
*/ | ||
public function add($id, $value, $expire = 0, $dependency = null); | ||
|
||
/** | ||
* Deletes a value with the specified key from cache | ||
* @param string $id the key of the value to be deleted | ||
* @return boolean whether the deletion is successful | ||
*/ | ||
public function delete($id); | ||
|
||
/** | ||
* Deletes all values from cache. | ||
* Be careful of performing this operation if the cache is shared by multiple applications. | ||
* @return boolean whether the flush operation was successful. | ||
*/ | ||
public function flush(); | ||
} |
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,41 @@ | ||
<?php | ||
/** | ||
* | ||
* | ||
* All rights reserved. | ||
* | ||
* @author Falaleev Maxim | ||
* @email max@studio107.ru | ||
* @version 1.0 | ||
* @company Studio107 | ||
* @site http://studio107.ru | ||
* @date 09/06/14.06.2014 17:43 | ||
*/ | ||
|
||
namespace Mindy\Cache; | ||
|
||
/** | ||
* ICacheDependency is the interface that must be implemented by cache dependency classes. | ||
* | ||
* This interface must be implemented by classes meant to be used as | ||
* cache dependencies. | ||
* | ||
* Objects implementing this interface must be able to be serialized and unserialized. | ||
* | ||
* @author Qiang Xue <qiang.xue@gmail.com> | ||
* @package Mindy\Base | ||
* @since 1.0 | ||
*/ | ||
interface ICacheDependency | ||
{ | ||
/** | ||
* Evaluates the dependency by generating and saving the data related with dependency. | ||
* This method is invoked by cache before writing data into it. | ||
*/ | ||
public function evaluateDependency(); | ||
|
||
/** | ||
* @return boolean whether the dependency has changed. | ||
*/ | ||
public function getHasChanged(); | ||
} |