Skip to content

Instantly share code, notes, and snippets.

@guilhermeblanco
Created October 14, 2013 20:08
Show Gist options
  • Save guilhermeblanco/6981395 to your computer and use it in GitHub Desktop.
Save guilhermeblanco/6981395 to your computer and use it in GitHub Desktop.
PSR 8 - Multi-operation Cache
<?php
namespace Psr\Cache;
interface CacheInterface extends PSR6SimplifiedCacheInterface, \IteratorAggregate
{
/**
* Gets a collection of entries from the CacheInterface, returning them as
* Map of the values associated with the set of keys requested.
* If no TransactionInterface 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|TransactionInterface $transaction
*
* {@internal Considering PSR 7 - Managed Cache, these are the Exception to support}
*
* @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<EntryInterface>
*/
public function getAll(TransactionInterface $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 TransactionInterface $transaction
*
* {@internal Considering PSR 7 - Managed Cache, these are the Exception to support}
*
* @throws Exception\IllegalStateException
* @throws Exception\CommunicationException
* @throws Exception\TransactionException
* @throws \InvalidArgumentException
*
* @return boolean
*/
public function setAll(TransactionInterface $transaction);
/**
* Removes entries for the specified keys.
* The order in which the individual removes will occur is undefined.
* In case no TransactionInterface is provided, all entries under this
* Cache will be removed. Not all drivers may be able to support it,
* like Memcache.
*
* @param null|TransactionInterface $transaction
*
* {@internal Considering PSR 7 - Managed Cache, these are the Exception to support}
*
* @throws Exception\IllegalStateException
* @throws Exception\CommunicationException
* @throws Exception\TransactionException
* @throws \InvalidArgumentException
*
* @return boolean
*/
public function unsetAll(TransactionInterface $transaction = null);
/**
* Checks existance of a collection of entries from the CacheInterface,
* returning them as a Map of the check results associated with the set
* of keys requested.
*
* @param TransactionInterface $transaction
*
* {@internal Considering PSR 7 - Managed Cache, these are the Exception to support}
*
* @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(TransactionInterface $transaction);
}
<?php
namespace Psr\Cache;
use Spl\Collection; /* Yes, we can dream! */
class TransactionInterface extends Collection
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment