Skip to content

Latest commit

 

History

History
186 lines (125 loc) · 4.53 KB

commands.md

File metadata and controls

186 lines (125 loc) · 4.53 KB

Supported commands

This documentation page provides a comprehesive guid to the commands supported by zcached, including their usage and sytanx.

PING

Available since: 0.0.1
Time complexity: O(1)

Checks if the server is running.

PING

GET

Available since: 0.0.1
Time complexity: O(1)

Get the value associated with key, returns not found error if key not found. Key should be always string.

GET <key>

SET

Available since: 0.0.1
Time complexity: O(1)

Set the value of a key.

SET <key> <value>

DELETE

Available since: 0.0.1
Time complexity: O(N) where N is the number of keys that will be removed. When a key to remove holds a value other than a string, the individual complexity for this key is O(M) where M is the number of elements in the list, set, sorted set or hash. Removing a single key that holds a string value is O(1).

Delete a key and its associated value. If everythings is okay OK returned, if not found not found error.

DELETE <key>

FLUSH

Available since: 0.0.1
Time complexity: O(N) where N is the total number of keys in databases

Delete all the keys from database. This command never fails.

FLUSH

DBSIZE

Available since: 0.0.1
Time complexity: O(1)

Returns the number of keys in the database.

DBSIZE

SAVE

Available since: 0.0.1
Time complexity: O(N) where N is the total number of keys in databases

The SAVE commands performs a synchronous save of the dataset producing a point in time snapshot of all the data inside the zcached instance, in the form of an zcpf file.

For asynchronous save check asave (not implemented yet).

SAVE

MGET

Available since: 0.0.1
Time complexity: O(N) where N is the number of keys to retrieve

Returns the values of all specified keys. For every key that does not hold a string value or does not exist, the special value null is returned. Because of this, the operation never fails.

MGET <key1> <key...>

MSET

Available since: 0.0.1
Time complexity: O(N) where N is the number of keys to set

Sets the given keys to their respective values. MSET replaces existing values with new values, just as regular SET. See MSETNX if you don't want to overwrite existing values.

MSET key value [key value ...]

KEYS

Available since: 0.0.1
Time complexity: O(N) where N is the total number of keys in databases

Returns all keys matching in database.

KEYS

LASTSAVE

Available since: 0.0.1
Time complexity: O(1)

Returns the Unix timestamp of the last successful DB save. If there wasn't any successful save, it returns the startup timestamp. Because of this, the operation never fails.

LASTSAVE

SIZEOF

Available since: 0.1.0
Time complexity: O(1)

Returns the size of the specified key based on its type. The size is calculated according to the following criteria:

Type Description
String / Simple string Length of the string.
Array Number of elements in the array.
Map The count of key-value pairs.
Set (not implemented yet) Number of elements in the set.
Integer Number of bytes the integer occupies.
Float Number of bytes the float occupies.
Null Always zero.
Boolean Always one.
SIZEOF <KEY>

ECHO

Available since: 0.1.0
Time complexity: O(1)

The ECHO command is used to return the given string as a response. For example: ECHO Hello Neptun! should return Hello Neptun!.

ECHO <Message>

RENAME

Available since: 0.1.0
Time complexity: O(1)

The RENAME command renames an existing key to a new key. If the new key already exists, it will be overwritten by the old key's value.

RENAME <Old key> <New key>

COPY

Available since: 0.1.0
Time complexity: O(N) where N is the number of nested items. O(1) for string values.

This command copies the value stored at the source key to the destination key. The command returns error when the destination key already exists. The optional REPLACE param removes the destination key before copying the value to it.

COPY <source> <destination> [REPLACE]