Skip to content

Instantly share code, notes, and snippets.

@AmyStephen
Created January 16, 2013 04:43
Show Gist options
  • Save AmyStephen/4544692 to your computer and use it in GitHub Desktop.
Save AmyStephen/4544692 to your computer and use it in GitHub Desktop.
Simple Cache Interface
<?php
interface Cache
{
/**
* Does cache exist for the key?
*
* @param string $key Key value used to store cache
*
* @return bool
*/
public function exists($key);
/**
* Get cache for the key
*
* @param string $key Key value used to store cache
*
* @return mixed
*/
public function get($key);
/**
* Remove cache entry for the specified key
*
* @param string $key Key value used to store cache
*
* @return bool
*/
public function delete($key);
/**
* Save data in cache using the key value provided
*
* @param string $key Key value for the cache entry
* @param mixed $data Value to store as a cache entry
* @param int $ttl Time To live in seconds
*
* @return bool
*/
public function put($key, $value, $ttl = 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment