SSDB PHP program api documentation
SSDB PHP Client API Documentation
- @Updated: 2014-11-05
SSDB is a High-performance NoSQL database, supports zset data structure, used to replace Redis. The official website is http://ssdb.io. This document introduces the PHP client API of SSDB.
Note : The nouns "hashmap", "hash", and "map" used by SSDB have the same meaning.
Class SimpleSSDB
Quick Start
<?php include_once('SSDB.php'); try{ $ssdb = new SimpleSSDB('127.0.0.1', 8888); }catch(SSDBException $e){ die(LINE . ' ' . $e->getMessage()); } $ret = $ssdb->set('key', 'value'); if($ret === false){ // error! } echo $ssdb->get('key');
Error handling
If unable to connect to the SSDB server, SimpleSSDB will throw an exception. Most methods (With a few exceptions) an error is indicated by returning false
. So use forced equals (===) to determine the return value.
If a network error occurs, all The method will throw SSDBException.
Note: Due to implementation reasons, please ensure that the total size of all parameters does not exceed 10MB.
Method
SimpleSSDB::__construct
Description
Create an instance of SimpleSSDB, and connect to the SSDB server. If unable to connect to the server, an exception will be thrown.
Parameters
host
- SSDB server Host name or IP.port
- The port number of the SSDB server.timeout_ms
- Optional, connection timeout, and sending and receiving data The timeout period, in milliseconds. The default is 2000 ms.
Return value
Instance of SimpleSSDB.
Example
$ssdb = new SimpleSSDB('127.0.0.1', 8888);
auth
Since: 1.7.0.0
Description
Configure the password, which will be used to verify with the server later. This verification is not performed immediately, but is sent to the server when you execute the first command. Note that the password is transmitted in clear text!
Parameters
password
-
Return value
If an error occurs, false
is returned, otherwise null
.
Example
$ssdb->auth('very-strong-password');
set
Description
Set the value content of the specified key.
Parameters
key
-value
-
Return value
Return on error false
, other values indicate normal.
Example
$ssdb->set('key', 'value');
setx
Description
Set the value content of the specified key and set the survival time.
Parameters
key
-value
-ttl
- Survival time (seconds)
Return value
If an error occurs, false
will be returned, other values mean normal.
Example
$ssdb->setx('key', 'value', 60);
setnx
Description
When the key does not exist, set the value content of the specified key. If it already exists, it will not be set.
Parameters
key
-value
-
Return value
If an error occurs, false
will be returned. 1: value has been set, 0: key already exists and will not be updated.
Example
$ssdb->setnx('key', 'value');
expire
Description
Set the survival time of key (only for KV type).
Parameters
key
-ttl
- Survival time (seconds)
Return value
If an error occurs, false
is returned. If the key exists and is set successfully, 1 is returned. If the key does not exist, 0 is returned.
Example
$ssdb->expire('key', 60);
ttl
Description
Returns the survival time of key (only for KV type).
Parameters
key
-
Return value
If an error occurs, false
will be returned. Otherwise, the survival time of the key (seconds) will be returned. -1 means that the survival time is not set.
Example
$ssdb->ttl('key');
get
Description
Get the specified key Value content.
Parameters
key
-
Return value
If the key does not exist, return null
, if an error occurs, return false
, otherwise return the value corresponding to the key.
Example
$ssdb->get('key');
getset
Description
Update the value corresponding to the key and return the old value before the update .
Parameter
key
-value
-
Return value
If the key does not exist, return null
, if an error occurs, return false
, otherwise return the value corresponding to the key Content.
Example
$ssdb->getset('key', 'value');##del
Description
Delete the specified key.Parameters
key
-
Return value
If an error occurs, false
is returned, and other values indicate normal. You cannot use the return value to determine whether the deleted key exists.
Example
$ssdb->del('key');
incr
From 1.7.0.1, if value cannot be converted to an integer, incr will return an error.
Instructions
Increase the value corresponding to key
by num
. The parameter num
can be a negative number . If the original value is not an integer (integer in string form), it will be converted to an integer first.
Parameters
key
-num
- Optional, must be a signed integer, the default is 1.
Return value
If an error occurs, return false
, otherwise return the new value.
Examples
$ssdb->incr('key', 1);##exists
Description
Judgment Whether the specified key exists.Parameters
- key
-
Return value
If exists, returntrue, otherwise return
false.
Example$ssdb->exists('key');
getbitDescription
Get the bit value (BIT) at the specified position in the string.Parameters
- key
-
- offset
- Bit offset
Return value
Returns the bit value (0 or 1). If the key does not exist or the offset exceeds the live string length range, 0 is returned.Example
$ssdb->getbit('key', 9);
setbit
Description
Setting The bit value (BIT) at the specified position in the string, the length of the string will be automatically extended.
Parameters
key
-offset
- Bit offset, value range [0, 1073741824]val
- 0 or 1
Return value
Return the original bit value. If val is not 0 or 1, return false
.
Example
$ssdb->setbit('key', 9, 1);
bitcount
Description
Calculate the number of bits contained in a substring of a string The number of values is 1. If start
is a negative number, it is counted from the end of the string. If end
is a negative number, it is counted from the end of the string (inclusive). Similar Redis bitcount
Parameters
key
-start
- Optional, byte offset of the substring Shiftend
- Optional
Return value
Return the number of bits whose value is 1. Error Return false
.
Example
$ssdb->bitcount('key', 2, 10);
countbit
Description
Calculate the number of bit values 1 contained in the substring of the string. If start
is a negative number, count from the end of the string. If size
is a negative number, which means that many bytes are ignored from the end of the string.
Parameters
key
-start
- Optional, the byte offset of the substringsize
- Optional, the length of the substring ( Number of bytes), the default is to the last byte of the string
Return value
Returns the number of bits with a bit value of 1. Returns on error false
.
Example
$ssdb->countbit('key', 2, 10);
substr
#Description
Get A substring of a string. If start
is a negative number, it starts from the end of the string. If size
is a negative number, it means it starts from the end of the string and ignores that many characters. Section (similar to PHP’s substr()).
Parameters
key
-start
- optional, int, byte offset of the substringsize
- optional, int, length of the substring (number of bytes) , the default is to the last byte of the string
Return value
The substring of the string.
Example
$ssdb->substr('key', 2, 10);
strlen
Description
Calculate the length of the string (number of bytes ).
Parameters
key
-
Return value
Returns the length of the string. If key does not exist, 0 is returned.
Example
$ssdb->strlen('key');
keys/rkeys
Description
List the key list in the interval (key_start, key_end].
("", ""] represents the entire interval.
Parameters
key_start
- Returned starting key (not included), empty string means -inf.-
key_end
- The returned end key (inclusive), the empty string represents +inf. limit
- The maximum number of elements returned.
Return value
If an error occurs, return false
, otherwise return an array containing the key.
Example
$ssdb->keys('a', 'z', 10);
scan
Description
Column Key-value list from the interval (key_start, key_end].
("", ""] represents the entire interval.
Parameters
key_start
- The returned starting key (not included), an empty string indicates -inf.key_end
- The returned end key (included), An empty string represents +inf.limit
- This many elements can be returned at most.
Return value
If an error occurs, return false
, otherwise return a number association group containing key-value.
Example
$ssdb->scan('a', 'z', 10);Traverse the key-value pair list
$start = ''; $limit = 1000; while(1){ $kvs = $ssdb->scan($start, '', $limit); if(!$kvs){ break; } // do something on key-value pairs... $keys = array_keys(array_slice($kvs, -1, 1, true)); $max_key = $keys[0]; $start = $max_key; }
rscan
Description
The list is in the interval ( key_start, key_end] key-value list, in reverse order.
("", ""] represents the entire interval.
Parameters
key_start
- Returned starting key (not included), empty string means +inf.-
key_end
- Returned end key (inclusive), empty string means -inf. limit
- Return at most this many elements.
Return value
If an error occurs, return false
, otherwise return a number association group containing key-value.
Example
$ssdb->rscan('a', 'z', 10);
multi_set
Description
Set a batch of key-values in batches.
Parameters
kvs
- Associative array containing key-value.
Return value
If an error occurs, it will return false
, other values indicate normal.
Example
$ssdb->multi_set(array( 'a' => 1, 'b' => 2, ));
multi_get
Description
Get the value content corresponding to a batch of keys in batches.
Parameters
keys
- Array containing key.
Return value
If an error occurs, false
is returned, otherwise an associative array containing key-value is returned. If a key does not exist, it will not appear in the return array.
Example
$ssdb->multi_get(array('k1', 'k2'));
multi_del
Description
Delete a batch in batches key and its corresponding value content.
Parameters
keys
- Array containing key.
Return value
If an error occurs, false
will be returned. Other values indicate normal.
Example
$ssdb->multi_del(array('k1', 'k2'));
hset
Description
Set the value content corresponding to the specified key in the hashmap.
Parameters
name
- The name of the hashmap.key
- The key in the hashmap.value
- The value content corresponding to key.
Return value
If an error occurs, false will be returned
, other values indicate normal.
Example
$ssdb->hset('h', 'key', 'value');
hget
Description
Get the value content of the specified key in the hashmap.
Parameters
name
- The name of the hashmap.key
- the key in the hashmap.
Return value
If the key does not exist Then return null
, if an error occurs, return false
, otherwise return the value corresponding to the key.
Example
$ssdb->hget('h', 'key');##hdel
Description
Get The specified key in the hashmap.Parameters
- name
- The name of the hashmap.
- key
- key in hashmap.
Return value
If an error occurs, it returnsfalse, other values mean normal. You It is impossible to judge whether the deleted key exists through the return value.
Example$ssdb->hdel('h', 'key');
hincrFrom 1.7.0.1, if value cannot be converted to an integer, incr will return an error.
Instructions
Enable # in hashmap ##key The corresponding value is increased by Returns if an error occurs Determine whether the specified key exists in the hashmap. If it exists, return Returns the number of elements in the hashmap. If an error occurs, List the hashmap whose names are in the interval (name_start, name_end]. ("", ""] represents the entire interval. false false If an error occurs, return List the key-value list in the interval (key_start, key_end] in the hashmap. ("", ""] represents the entire range. If an error occurs, return Traverse hash: List the keys in the hashmap in the interval (key_start, key_end]- value list, in reverse order. ("", ""] represents the entire interval. If an error occurs, return Delete all keys in the hashmap. If an error occurs, return Batch set the key-value in hashmap. If an error occurs, Get the weight values corresponding to multiple keys in the hashmap in batches. If an error occurs, return Delete keys in hashmap in batches. Return on error Set the weight value corresponding to the specified key in zset. If an error occurs, it will be returned Get the weight value of the specified key in zset. If the key is not If it exists, it returns false key If an error occurs, true If an error occurs, List the zset.## whose names are in the interval (name_start, name_end] is returned, otherwise the name is returned Array of . Column Get the key list in zset. See Return if an error occurs (key.score == score_start && key > key_start || key. score > score_start), and key.score <= score_end false List the key-score list in zset, in reverse order. See If an error occurs, return Attention! This method may be very slow! Please use it in an offline environment. Returns the sorting position (ranking) of the specified key in zset, ranking starts from 0. zrrank gets the reverse order ranking. If an error occurs, Note! This method will become slower as the offset gets larger and larger! Get the key-score pair according to the subscript index interval [offset, offset + limit), the subscript starts from 0 . zrrange is obtained in reverse order. If an error occurs, return Delete all keys in zset. If an error occurs Return Returns the number of keys in the interval [start,end]. If an error occurs, return Returns the sum of the scores of the key in the interval [start,end] . If an error occurs, return false If an error occurs, Delete elements whose weight is in the interval [start,end]. If an error occurs, From The zset header deletes and returns If an error occurs, return Delete and return If an error occurs, Batch set key-score in zset. If an error occurs, # will be returned ##false If an error occurs, return Delete keys in zset in batches. Return in case of error Returns the length of the queue. Return List the queue/list whose names are in the interval (name_start, name_end]. ("", ""] represents the entire interval. If an error occurs, Clear A queue. Error return false Return The last element of the queue. If an error occurs, Returns the element at the specified position. 0 means the first element, 1 is the second... -1 is the last. Error return Since: 1.7.0.0 Update the element located at index position. If it exceeds the existing element range, an error will be returned. If an error occurs, Returns the element whose subscript is in the area [offset, offset + limit]. If an error occurs, return Returns the element whose subscript is in the area [begin, end]. begin and end can Is a negative number If an error occurs, qpush_back() After adding elements, the length of the queue, error return This function is Pop one from the head of the queue Or multiple elements. Error returns From Pop one or more elements from the end of the queue. false From Delete multiple elements from the head of the queue. Return on error Delete multiple elements from the head of the queue. Error return Execute a batch of commands in batches. Batch commands can reduce the interaction delay between the client and the server, and improve performance and response speed. This feature is implemented on the client, ssdb-server Batch commands are not supported, but are executed one by one as independent commands. The size of all commands and parameters should be less than 10MB. If Returns the estimated size of the database, in bytes. If the server has compression enabled, returns the compressed size. Error return Return server information. Error return num
. The parameter num
can be a negative number. If the original value is not an integer (an integer in string form), it will be converted to Integer.Parameters
name
- The name of the hashmap.key
-num
- Optional, must be a signed integer, the default is 1.Return value
false
, otherwise return the new value.Example
$ssdb->hincr('h', 'key', 1);
hexists
Description
Parameters
name
- The name of the hashmap.key
-Return value
true
, otherwise return false
.Example
$ssdb->hexists('h', 'key');
hsize
Description
Parameters
name
- The name of the hashmap.Return value
false
is returned, otherwise the number of elements is returned, 0 means there is no hashmap (empty).Example
$ssdb->hsize('h');
hlist, hrlist
Description
Parameters
- The starting name returned (not included), the empty string represents -inf.
- the returned end name (not included), the empty string represents +inf.
- Returns at most this many elements.
Return value
If an error occurs, will be returned, and the return value includes the name Array of .
Example
$ssdb->hlist('a', 'z', 10);
##hkeysDescription
Column Output the key list in the hashmap in the interval (key_start, key_end].("", ""] represents the entire interval.Parameters
- The name of the hashmap.
- The starting key (not included), an empty string means -inf.
- End key (inclusive), empty string means +inf.
- Return at most this many elements.
Return value
If an error occurs, return , otherwise return an array containing the key.
Example
hgetall$ssdb->hkeys('h', 'a', 'z', 10);
Description
Return the entire hashmap.Parameters
name
- The name of the hashmap.Return value
false
, otherwise return an associative array containing key-value.Example
$ssdb->hgetall('h');
hscan
Description
Parameters
name
- The name of the hashmap.key_start
- Returned starting key (not included), empty string means -inf.key_end
- Returned end key (included), empty String representation +inf.limit
- Return at most this many elements.Return value
false
, otherwise return an associative array containing key-value.Example
$ssdb->hscan('h', 'a', 'z', 10);
$start = '';
while(1){
$kvs = $ssdb->hscan($name, $start, '', 10);
if(!$kvs){
break;
}
// do sth on kvs here$keys = array_keys($kvs);$start = $keys[count($keys) - 1];}
hrscan
Description
Parameter
name
- The name of the hashmap.key_start
- The returned starting key (not included), the empty string represents +inf.key_end
- Returned end key (inclusive), empty string means -inf.limit
- Return at most this many elements.Return value
false
, otherwise return an associative array containing key-score.Example
$ssdb->hrscan('h', 'a', 'z', 10);
hclear
Description
Parameters
name
- The name of the hashmap.Return value
false
, otherwise return the number of deleted keys.Example
$ssdb->hclear('h');
multi_hset
Description
Parameters
name
- The name of the hashmap.kvs
- Associative array containing key-value. Return value
false
will be returned. Other values indicate normal.Example
$ssdb->multi_hset('h', array(
'a' => 1,
'b' => 2,
));
multi_hget
Description
Parameters
name
- The name of the hashmap. keys
- An array containing keys. Return value
false
, otherwise return an associative array containing key-value. If a key does not exists, it will not appear in the return array.Example
$ssdb->multi_hget('h', array('k1', 'k2'));
multi_hdel
Instructions
Parameters
name
- The name of the hashmap.keys
- The array containing the key.Return value
false
, other values indicate normal.Example
$ssdb->multi_hdel('h', array('k1', 'k2'));
zset
Description
Parameters
name
- The name of zset. key
- The key in zset. score
- Integer, the weight value corresponding to the keyReturn value
false
, other values indicate normal.Example
$ssdb->zset('z', 'key', 100);
zget
Description
Parameters
name
- The name of the zset.key
- The key in the zset.Return value
null
, if there is an error, it returns false
, otherwise it returns the weight value corresponding to the key.Example
$ssdb->zget('z', 'key');
##zdelDescription
Get The specified key in zset.Parameters
- The name of zset.
- key.
Return value
If an error occurs, it will return , other values mean normal. You It is impossible to judge whether the deleted key exists through the return value.
Example
zincr$ssdb->zdel('hz, 'key');
Description
Increase the value corresponding to in zset by
num. The parameter
num can be a negative number. If the original value is not an integer (integer in string form), it will be converted to an integer first.
Parameters
name
- The name of zset.key
-num
- must be a signed integer. Return value
false
will be returned. Otherwise return the new value. Example
$ssdb->zincr('z', 'key', 1);
##zexistsDescription
Determine whether the specified key exists in zset.Parameters
- zset Name.
-
Return value
If exists, return , otherwise return
false.
Example
##zsize$ssdb->zexists('z', 'key');
DescriptionReturns the number of elements in zset.
Parameters
name
- The name of zset.Return value
false
is returned, otherwise the number of elements is returned, 0 means there is no zset (empty).Example
$ssdb->zsize('z');
zlist, zrlist
Description
Parameters
##name_start
Return value If an error occurs,
falseExample
$ssdb->zlist('a', 'z', 10);
zkeys
Description
zscan()
.parameter
name
- The name of the zset.key_start
- See zscan()
.score_start
- See zscan()
.score_end
- See zscan()
.limit
- Return at most this many elements.Return value
false
, otherwise return an array containing key.Example
$ssdb->zkeys('z', '', 1, 100, 10);
##zscanDescription
Column Extract the key-score list in the zset that is in the interval (key_start+score_start, score_end]. If key_start is empty, then the keys whose corresponding weight value is greater than or equal to score_start will be returned. If key_start is not empty, then the corresponding weight value is greater than score_start. key, or a key that is greater than key_start and has a corresponding weight value equal to score_start will be returned.In other words, the returned key is in interval.
First judge score_start, score_end, and then judge key_start.Parameters
- The name of zset.
- The key corresponding to score_start.
- Returns the minimum weight value of the key (may not be included, depends on key_start), the empty string means -inf.
- Returns the maximum weight value of key (inclusive), an empty string represents +inf.
- Returns at most this many elements.
Return value
If an error occurs, return , otherwise return an associative array containing key-score.
Example
Traverse zset:$ssdb->zscan('z', '', 1, 100, 10);
$key_start = '';
$score_start = '';
while(1){
$items = $ssdb->zscan($zname, $key_start, $score_start, '', 10);
if(!$items){
break;
}
foreach($items as $key=>$score){
// process($key, $score)... // 记住最大的元素和它的权重
$key_start = $key;
$score_start = $score;
}
}
zrscan
Description
zkeys()
.Parameters
name
- the name of the zset .key_start
- See zkeys()
.score_start
- See zkeys()
.score_end
- See zkeys()
.limit
- Return at most this many elements.Return value
false
, Otherwise, return an associative array containing key-score.Example
$ssdb->zrscan('z', '', 100, 1, 10);
zrank, zrrank
Instructions
Parameters
name
- The name of zset.key
-Return value
found .false
will be returned, null
means the key does not exist in zset, otherwise the ranking will be returned.Example
$ssdb->zrank('z', 'k1');
zrange, zrrange
Description
Parameters
name
- the name of zset.offset
- a positive integer, from now on Start returning at the index. Start from 0.limit
- Positive integer, return at most this many key-score pairs.Return value
false
, otherwise return an associative array containing key-score.Example
$ssdb->zrange('z', 0, 10);
zclear
Description
Parameters
name
- The name of zset.Return value
false
, otherwise return the number of deleted keys.Example
$ssdb->zclear('z');
zcount
Description
Parameters
name
- The name of the zset. score_start
- The minimum weight value of the key (Inclusive), the empty string represents -inf.score_end
- the maximum weight value of key (Inclusive), the empty string represents +inf. Return value
false
, otherwise return the number of keys that meet the conditions.Example
$ssdb->zcount('z', 0, 100);
zsum
Explanation
Parameters
name
- the name of zset.score_start
- key The minimum weight value of key (inclusive), the empty string represents -inf.score_end
- The maximum weight value of key (inclusive), the empty string represents +inf.Return value
false
, otherwise return the sum of the scores that meet the conditions.Example
$ssdb->zsum('z', 0, 100);
##zavgDescription
Return The key is the average value of the scores in the interval [start, end].Parameters
- The name of the zset.
- The minimum weight value of key (inclusive), an empty string indicates -inf.
- The maximum weight value of key (inclusive) , an empty string represents +inf.
Return value
If an error occurs, is returned, otherwise a score that meets the conditions is returned Average.
Example
##zremrangebyrankDescription$ssdb->zavg('z', 0, 100);
Delete elements whose position is in the interval [start,end].
Parameters
name
- The name of zset.start
- (Inclusive).end
-(Inclusive).Return value
false
will be returned , otherwise return the number of deleted elements.Example
$ssdb->zremrangebyrank('z', 1, 2);
zremrangebyscore
Description
Parameters
name
- The name of the zset.start
- (Inclusive).end
-(Inclusive).Return value
false
is returned, otherwise the number of deleted elements is returned.Example
$ssdb->zremrangebyscore('z', 1, 2);
zpop_front
Description
limit
elements.Parameters
name
- The name of the zset.limit
- A positive integer, the maximum number of key-score pairs to be deleted and returned.Return value
false
, otherwise return an associative array containing key-score.Example
$ssdb->zpop_front('z', 3);
zpop_back
Description
limit
elements from the end of zset.Parameters
name
- the name of zset.limit
- a positive integer, at most Delete and return so many key-score pairs.Return value
false
is returned, otherwise the key is returned Associative array of -score.Example
$ssdb->zpop_back('z', 3);
multi_zset
Description
Parameters
name
- the name of zset .kvs
- Associative array containing key-score.Return value
, other values indicate normal.
Example
multi_zget$ssdb->multi_zset('z', array(
'a' => 1,
'b' => 2,
));
Instructions
Get the weight values corresponding to multiple keys in zset in batches.Parameters
name
- The name of zset. keys
- An array containing keys. Return value
false
, otherwise return an associative array containing key-score. If a key does not exists, it will not appear in the return array.Example
$ssdb->multi_zget('z', array('k1', 'k2'));
multi_zdel
Instructions
Parameters
name
- The name of zset.keys
- The array containing key.Return value
false
, other values indicate normal.Example
$ssdb->multi_zdel('z', array('k1', 'k2'));
qsize
Description
Parameters
name
-Return value
false
on error, otherwise return an integer, 0 means the queue does not exist (or is empty).Example
$ssdb->qsize('q');
qlist, qrlist
Description
Parameters
name_start
- The returned starting name (not included ), the empty string represents -inf.name_end
- the returned end name (inclusive), the empty string represents +inf.limit
- Return at most this many elements. Return value
false
will be returned, and an array containing the name will be returned. Example
$ssdb->qlist('a', 'z', 10);
qclear
Description
Parameters
name
-Return value
false
.Example
$ssdb->qclear('q');
##qfrontDescription
Returns the first element of the queue.Parameters
-
Return value
If an error occurs, will be returned. If the queue does not exist (or is empty), # will be returned. ##null
, otherwise return an element.Example
$ssdb->qfront('q');
qback
Description
Parameters
name
-Return value
false
is returned. If the queue does not exist (or is empty), null
is returned. Otherwise, an element is returned.Example
$ssdb->qback('q');
qget
Description
Parameters
name
-index
- Negative numbers can be passed.Return value
false
, If an element does not exist at the specified position, return null
, otherwise return an element.Example
$ssdb->qget('q', -2);
qset
Description
Parameters
name
-index
- Can pass negative numbers.val
- Return value
false
will be returned. Other values indicate normal.Example
$ssdb->qset('q', 0, 'new val');
qrange
Description
Parameters
name
- The name of the queue.offset
- Integer, from here on out Start returning from 0. It can be a negative number, which means counting from the end. limit
- a positive integer, up to this many elements can be returned. Return value
false
, otherwise return an array.Example
$ssdb->qrange('q', 0, 10);
qslice
Description
Parameter
name
-begin
-end
-Return value
false
is returned, otherwise an array containing the elements is returned. Example
$ssdb->qslice('q', 0, -1);
##qpushDescription
this The function is an alias of .
Add one or more elements to the head of the queue
Parameters##name
-
item
After adding elements, the length of the queue, returned in case of error false
.Example
##qpush_backDescription$ssdb->qpush_front('q', 'a');
Add one or more elements to the end of the queue
Parameters
name
-item
- String or string array.Return value
false
.Example
$ssdb->qpush_back('q', 'a');
qpop
Description
qpop_front( )
alias.qpop_front
Description
Parameters
name
-size
- Optional, up to this many can be popped from the queue ElementsReturn value
false
. When size
is not specified or is less than or equal to 1 , if the queue does not exist (or is empty), return null
, otherwise delete and return an element. When size
is greater than or equal to 2, return an array containing the popped element.Example
$ssdb->qpop_front('q');
qpop_back
Instructions
Parameters
-
- Optional, at most this many elements can be popped from the queue
Return value
Error returns . When ## When #size
is not specified or is less than or equal to 1, if the queue does not exist (or is empty), null
will be returned, otherwise an element will be deleted and returned. When size
is greater than or equal to 2 , returns an array containing the popped elements.Example
$ssdb->qpop_back('q');
qtrim_front
Instructions
Parameters
name
-size
- Delete at most this many elements from the queue Return value
false
. Returns the number of deleted elements. Example
$ssdb->qtrim_front('q', 3);
qtrim_back
Description
Parameters
name
- size
- The maximum number of elements to be deleted from the queueReturn value
false
. Return the deleted Number of elements.Example
$ssdb->qtrim_back('q', 3);
batch, exec
Description
Parameters
Return value
exec()
makes an error, it returns false
, otherwise it returns one The array contains the results corresponding to each command.Example
$ret = $ssdb->batch()
->set('a', 1)
->get('a')
->exec();
// 或者
$ssdb->batch();
$ssdb->set('a', 1);
$ssdb->get('a');
$ret = $ssdb->exec();
dbsize
Description
Parameters
Return value
false
. Returns the database size. Example
$ssdb->dbsize();
info
Description
Parameters
opt
- Optional, can be cmd, leveldb
Return value
false
. Returns an associative array of server information. Example
$ssdb->info();