86 lines
2.2 KiB
PHP
86 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; under version 2
|
|
* of the License (non-upgradable).
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
* Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
|
|
*
|
|
* @author Lionel Lecaque <lionel@taotesting.com>
|
|
* @license GPLv2
|
|
* @package generis
|
|
|
|
*
|
|
*/
|
|
|
|
/**
|
|
* Interface of drivers that provide the Kay Value Persistence
|
|
*
|
|
* @author Joel Bout <joel@taotesting.com>
|
|
*/
|
|
interface common_persistence_KvDriver extends common_persistence_Driver
|
|
{
|
|
|
|
/**
|
|
* Stores a value, implementing time to live and nx is optional
|
|
* Should throw an exception if an option is not supported
|
|
*
|
|
* @param string $id
|
|
* @param string $value
|
|
* @param string $ttl time to live in seconds
|
|
* @param bool $nx Only set the key if it does not already exist
|
|
* @return bool
|
|
*/
|
|
public function set($id, $value, $ttl = null, $nx = false);
|
|
|
|
/**
|
|
* Returns a value from storage
|
|
* or false if not found
|
|
*
|
|
* @param string $id
|
|
* @return string
|
|
*/
|
|
public function get($id);
|
|
|
|
/**
|
|
* test whenever or not an entry exists
|
|
*
|
|
* @param string $id
|
|
* @return boolean
|
|
*/
|
|
public function exists($id);
|
|
|
|
/**
|
|
* Remove an entry from storage
|
|
*
|
|
* @param string $id
|
|
* @return boolean
|
|
*/
|
|
public function del($id);
|
|
|
|
/**
|
|
* Increment value
|
|
*
|
|
* @param string $id
|
|
* @return boolean
|
|
*/
|
|
public function incr($id);
|
|
|
|
/**
|
|
* Decrement value
|
|
* @param $id
|
|
* @return boolean
|
|
*/
|
|
public function decr($id);
|
|
}
|