Created
April 14, 2014 04:14
-
-
Save guilhermeblanco/10615439 to your computer and use it in GitHub Desktop.
Cache ideas
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
<?php | |
namespace Doctrine\Cache; | |
use Doctrine\Cache\CacheEntry; | |
use Doctrine\Cache\Transaction; | |
class Cache extends \ArrayAccess | |
{ | |
/** | |
* Retrieve the Cache Manager. | |
* | |
* @return \Doctrine\Cache\CacheManager | |
*/ | |
public function getManager(); | |
/** | |
* Retrieve the Cache Configuration. | |
* | |
* @return \Doctrine\Cache\Configuration\CacheConfiguration | |
*/ | |
public function getConfiguration(); | |
/** | |
* Return the cache namespace. | |
* | |
* @return string | |
*/ | |
public function getNamespace(); | |
/** | |
* Retrieve a Cache Entry. | |
* | |
* @param string $key | |
* | |
* @throws Exception\IllegalStateException If the Cache Manager is closed. | |
* @throws Exception\CommunicationException If there was a problem fetching for key. | |
* @throws \InvalidArgumentException If argument could not be properly validated. | |
* Fetching should only validate if key is a string. | |
* | |
* @return \Doctrine\Cache\CacheEntry | |
*/ | |
public function get($key); | |
/** | |
* Define a Cache Entry. | |
* | |
* @param \Doctrine\Cache\CacheEntry $entry | |
* | |
* @throws Exception\IllegalStateException If the Cache Manager is closed. | |
* @throws Exception\CommunicationException If there was a problem fetching for key. | |
* @throws \InvalidArgumentException If argument could not be properly validated. | |
* (useful when subclassing EntryInterface). | |
* | |
* @return boolean | |
*/ | |
public function set(CacheEntry $entry); | |
/** | |
* Remove a Cache Entry. | |
* | |
* @param string $key | |
* | |
* @throws Exception\IllegalStateException If the Cache Manager is closed. | |
* @throws Exception\CommunicationException If there was a problem fetching for key. | |
* @throws \InvalidArgumentException If argument could not be properly validated. | |
* Fetching should only validate if key is a string. | |
* | |
* @return boolean | |
*/ | |
public function unset($key); | |
/** | |
* Check existance of a Cache Entry. | |
* | |
* @param string $key | |
* | |
* @throws Exception\IllegalStateException If the Cache Manager is closed. | |
* @throws Exception\CommunicationException If there was a problem fetching for key. | |
* @throws \InvalidArgumentException If argument could not be properly validated. | |
* Fetching should only validate if key is a string. | |
* | |
* @return boolean | |
*/ | |
public function isset($key); | |
/** | |
* Gets a collection of entries from the Cache, returning them as Map of the | |
* values associated with the set of keys requested. | |
* If no Transaction is provided, it will return all entries stored under | |
* this cache. Despite of performance implications and/or lock that may | |
* occur, not all drivers may be able to support it, like Memcache. | |
* | |
* @param null|Transaction $transaction | |
* | |
* @throws Exception\IllegalStateException | |
* @throws Exception\CommunicationException | |
* @throws Exception\TransactionException | |
* @throws \InvalidArgumentException | |
* | |
* @todo Discuss if this should return an Array or a Collection (Map). | |
* | |
* @return array<CacheEntry> | |
*/ | |
public function getAll(Transaction $transaction = null); | |
/** | |
* Copies all of the entries from the specified map to the CacheInterface. | |
* The effect of this call is equivalent to that of calling put(EntryInterface) | |
* on this cache once for each mapping from key to value in the specified map. | |
* Under drivers that are able to support XA Transactions, you will have an extra | |
* level of consistency of operation. | |
* | |
* @param Transaction $transaction | |
* | |
* @throws Exception\IllegalStateException | |
* @throws Exception\CommunicationException | |
* @throws Exception\TransactionException | |
* @throws \InvalidArgumentException | |
* | |
* @return boolean | |
*/ | |
public function setAll(Transaction $transaction); | |
/** | |
* Removes entries for the specified keys. | |
* The order in which the individual removes will occur is undefined. | |
* In case no Transaction is provided, all entries under this | |
* Cache will be removed. Not all drivers may be able to support it, | |
* like Memcache. | |
* | |
* @param null|Transaction $transaction | |
* | |
* @throws Exception\IllegalStateException | |
* @throws Exception\CommunicationException | |
* @throws Exception\TransactionException | |
* @throws \InvalidArgumentException | |
* | |
* @return boolean | |
*/ | |
public function unsetAll(Transaction $transaction = null); | |
/** | |
* Checks existance of a collection of entries from the Cache, | |
* returning them as a Map of the check results associated with the set | |
* of keys requested. | |
* | |
* @param Transaction $transaction | |
* | |
* @throws Exception\IllegalStateException | |
* @throws Exception\CommunicationException | |
* @throws Exception\TransactionException | |
* @throws \InvalidArgumentException | |
* | |
* @todo Discuss if this should return an Array or a Collection (Map). | |
* | |
* @return array<boolean> | |
*/ | |
public function issetAll(Transaction $transaction); | |
} |
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
<?php | |
namespace Doctrine\Cache\Configuration; | |
class CacheConfiguration | |
{ | |
/** | |
* Returns the configured cache namespace. | |
* | |
* @return string | |
*/ | |
public function getNamespace(); | |
/** | |
* Returns the configured expiry policy. | |
* | |
* @return \Doctrine\Cache\Expiry\ExpiryPolicy | |
*/ | |
public function getExpiryPolicy(); | |
} |
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
<?php | |
namespace Doctrine\Cache; | |
use Doctrine\Cache\Configuration\CacheConfiguration; | |
class CacheManager | |
{ | |
/** | |
* Retrieve the underlying cache storage implementation. | |
* | |
* @return \Doctrine\Cache\Provider\CachingProvider | |
*/ | |
public function getCachingProvider(); | |
/** | |
* Create a new Cache to be managed by the Cache Manager. | |
* | |
* @param string $name | |
* @param \Doctrine\Cache\Configuration\Configuration $configuration | |
* | |
* @return \Doctrine\Cache\Cache | |
*/ | |
public function createCache($name, Configuration $configuration); | |
/** | |
* Destroy a managed Cache instance. | |
* | |
* @param string $name | |
* | |
* @return void | |
*/ | |
public function destroyCache($name); | |
/** | |
* Retrieve a managed Cache instance. | |
* | |
* @param string $name | |
* | |
* @return \Doctrine\Cache\Cache | |
*/ | |
public function getCache($name); | |
/** | |
* Retrieve an Iterator of managed Cache instance names. | |
* | |
* @return array<string> | |
*/ | |
public function getCacheNameList(); | |
/** | |
* Close the Cache Manager. | |
* | |
* @return void | |
*/ | |
public function close(); | |
/** | |
* Check if the Cache Manager is closed. | |
* | |
* @return boolean | |
*/ | |
public function isClosed(); | |
/** | |
* Check if a requested feature is supported by Cache Manager. | |
* | |
* @param string $feature | |
* | |
* @return boolean | |
*/ | |
public function isSupported($feature); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment