1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62:
<?php
namespace Dropbox;
/**
* A contract for a class which provides simple get/set/clear access to a single string
* value. {@link ArrayEntryStore} provides an implementation of this for storing a value
* in a single array element.
*
* Example implementation for a Memcache-based backing store:
*
* <code>
* class MemcacheValueStore implements ValueStore
* {
* private $key;
* private $memcache;
*
* function __construct($memcache, $key)
* {
* $this->memcache = $memcache;
* $this->key = $key;
* }
*
* function get()
* {
* $value = $this->memcache->get($this->getKey());
* return $value === false ? null : base64_decode($value);
* }
*
* function set($value)
* {
* $this->memcache->set($this->key, base64_encode($value));
* }
*
* function clear()
* {
* $this->memcache->delete($this->key);
* }
* }
* </code>
*/
interface ValueStore
{
/**
* Returns the entry's current value or `null` if nothing is set.
*
* @return string
*/
function get();
/**
* Set the entry to the given value.
*
* @param string $value
*/
function set($value);
/**
* Remove the value.
*/
function clear();
}