/**
* Get an item with the given key. Returns false if it does not exist.
* @param $key string
- *
- * @return bool|Object
+ * @return mixed Returns false on failure
*/
abstract public function get( $key );
* Get an associative array containing the item for each of the given keys.
* Each item will be false if it does not exist.
* @param $keys Array List of strings
- *
* @return Array
*/
public function getBatch( array $keys ) {
* @param $key string
* @param $value mixed
* @param $exptime int Either an interval in seconds or a unix timestamp for expiry
+ * @return bool success
*/
abstract public function set( $key, $value, $exptime = 0 );
* Delete an item.
* @param $key string
* @param $time int Amount of time to delay the operation (mostly memcached-specific)
+ * @return bool success
*/
abstract public function delete( $key, $time = 0 );
+ /**
+ * @param $key string
+ * @param $timeout integer
+ * @return bool success
+ */
public function lock( $key, $timeout = 0 ) {
/* stub */
return true;
}
+ /**
+ * @param $key string
+ * @return bool success
+ */
public function unlock( $key ) {
/* stub */
return true;
}
+ /**
+ * @todo: what is this?
+ * @return Array
+ */
public function keys() {
/* stub */
return array();
/* *** Emulated functions *** */
+ /**
+ * @param $key string
+ * @param $value mixed
+ * @param $exptime integer
+ * @return bool success
+ */
public function add( $key, $value, $exptime = 0 ) {
if ( !$this->get( $key ) ) {
- $this->set( $key, $value, $exptime );
-
- return true;
+ return $this->set( $key, $value, $exptime );
}
+ return true;
}
+ /**
+ * @param $key string
+ * @param $value mixed
+ * @return bool success
+ */
public function replace( $key, $value, $exptime = 0 ) {
if ( $this->get( $key ) !== false ) {
- $this->set( $key, $value, $exptime );
+ return $this->set( $key, $value, $exptime );
}
+ return true;
}
/**
* @param $key String: Key to increase
* @param $value Integer: Value to add to $key (Default 1)
* @return null if lock is not possible else $key value increased by $value
+ * @return success
*/
public function incr( $key, $value = 1 ) {
if ( !$this->lock( $key ) ) {
return $n;
}
+ /**
+ * @param $key String
+ * @param $value Integer
+ * @return bool success
+ */
public function decr( $key, $value = 1 ) {
return $this->incr( $key, - $value );
}
+ /**
+ * @param $text string
+ */
public function debug( $text ) {
if ( $this->debugMode ) {
$class = get_class( $this );
/**
* Convert an optionally relative time to an absolute time
+ * @param $exptime integer
* @return int
*/
protected function convertExpiry( $exptime ) {
}
}
}
-
-