Permalink
Browse files

Updating and adding methods to the Bouncer cache interface.

  • Loading branch information...
1 parent e70fb4f commit be1cd57513b703414ed58948c21c33c1b1391b67 @brandonsavage brandonsavage committed Apr 1, 2013
View
56 bouncer/php/lib/cache_interface.php
@@ -0,0 +1,56 @@
+<?php
+
+interface Cache_Interface {
+
+ /**
+ * Get an item from the cache, if it exists
+ * @return mixed item if found, else false
+ */
+ public function get($key);
+
+ /**
+ * Store an item in the cache. Replaces an existing item.
+ * @return bool success
+ */
+ public function set($key, $var, $flag = null, $expire);
+
+ /**
+ * Store an item in the cache. Returns false if the key is
+ * already present in the cache.
+ * @return bool success
+ */
+ public function add($key, $var, $flag = null, $expire);
+
+ /**
+ * Store an item in the cache. Returns false if the key did
+ * NOT exist in the cache before.
+ * @return bool success
+ */
+ public function replace($key, $var, $flag = null, $expire);
+
+ /**
+ * Close the connection to _ALL_ cache servers
+ * @return bool success
+ */
+ public function close();
+
+ /**
+ * Delete something off the cache
+ * @return bool success
+ */
+ public function delete($key, $timeout = null);
+
+ /**
+ * Returns key in the appropriate namespace.
+ * @param string $key memcache key
+ * @return string Namespaced key
+ */
+ public function namespaceKey($key);
+
+ /**
+ * Flush the cache
+ * @return bool success
+ */
+ public function flush();
+
+}
View
6 bouncer/php/lib/memcaching.php
@@ -37,17 +37,17 @@
*
* ***** END LICENSE BLOCK ***** */
-interface Memcache_Interface {}
+require 'cache_interface.php';
/**
* This model is an interface to Memcache.
* It's called Memcaching to not interfere with the actual Memcache class.
*/
-class Memcaching implements Memcache_Interface {
+class Memcaching implements Cache_Interface {
var $cache; // holds the memcache object
var $memcacheConnected; // did we find a valid memcache server?
- function Memcaching() {
+ function __construct() {
global $memcache_config;
if (class_exists('Memcache') && defined('CACHE') && CACHE)
View
2 bouncer/php/lib/sdo2.php
@@ -34,7 +34,7 @@ class SDO2 {
protected $db_read;
protected $db_details;
- public function __construct(Memcache_Interface $mc, array $dbwrite = array(), array $dbread = array()) {
+ public function __construct(Cache_Interface $mc, array $dbwrite = array(), array $dbread = array()) {
$this->mc = $mc;
if(empty($dbwrite) && empty($dbread)) {
throw new Exception('No credentials supplied for database connection');
View
2 bouncer/tests/mocks/memcaching.php
@@ -6,7 +6,7 @@
* This model is an interface to Memcache.
* It's called Memcaching to not interfere with the actual Memcache class.
*/
-class Memcaching_Mock implements Memcache_Interface {
+class Memcaching_Mock implements Cache_Interface {
function get($key) {
return false;

0 comments on commit be1cd57

Please sign in to comment.