Commands

In order to connect to and interact with LSMCD, you can use telnet to connect to one of the IP addresses and port numbers set in Cached.Addr.

Note that telnet does not work with SASL as user authorization is incompatible with the unencrypted text in telnet.

For example, with the default settings, you would connect using the following command:

telnet 127.0.0.1 11211

The following is a list of LSMCD commands usable in telnet

add

Add a new key/value pair, but only if the server doesn’t already hold data for this key.

Syntax

add <key> <flags> <TTL> <length> [noreply]
<value>

Parameters

  • key - The name of the unique key by which data is accessed.
  • flags - The 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • TTL - The length of time (in seconds) the key/value pair will be stored in cache. A 0 value means the data will "never expire" and should not be removed from the cache unless required. If the TTL is more than 30 days then LSMCD interprets it as UNIX timestamp for expiration.
  • length - The length of the data in bytes that needs to be stored in LSMCD.
  • noreply - This optional parameter tells the server not to send any reply.
  • value - The data that needs to be stored. This parameter needs to be given on the new line after executing the command with the above options.

Example

Request

add newkey 0 120 10
myvalueabc

Response

STORED

Output Notes

  • 0: no flags
  • 120: store data for 2 minutes (120 seconds)
  • 10: data is 10 bytes long
  • myvalueabc: newkey will be associated with the value myvalueabc

Possible Errors

  • NOT_STORED: Indicates that the provided key already exists in the LSMCD server so the data associated with that key was not updated.

append

Add data to an existing key after existing data.

Syntax

append <key> <flags> <TTL> <length> [noreply]
<value>

Parameters

  • key - The name of the unique key by which data is accessed.
  • flags - A 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • TTL - The length of time (in seconds) the key/value pair will be stored in cache. A 0 value means the data will “never expire” and should not be removed from the cache unless required. If the TTL is more than 30 days then LSMCD interprets it as UNIX timestamp for expiration.
  • length - The length of the data in bytes that needs to be stored in LSMCD.
  • noreply - This optional parameter tells the server not to send any reply.
  • value - The data that needs to be stored. This parameter needs to be given on the new line after executing the command with the above options.

Example

Request

append mykey 0 120 10
defghijklm

Response

STORED

Output Notes

  • 0: no flags
  • 120: store data for 2 minutes (120 seconds)
  • 10: add 10 bytes of data to the end of mykey In this example, if mykey had a value of myvalueabc, after running append, its value would be myvalueabcdefghijklm.

Possible Errors

  • NOT_STORED: Indicates that the key does not exist in the LSMCD server and its data could not be modified.
  • CLIENT_ERROR: Indicates other errors such as syntax errors.

bget

Read the binary value from memory that is associated with the user-provided key.

Syntax

bget <key>

Parameters

  • key - The name of the unique key by which data is accessed.

Example

Request

bget mykey

Response

VALUE mykey 0 10
abcdefghij
END

Output Notes

  • 0: no flags
  • 10: data is 10 bytes long
  • myvalueabc: "mykey" is associated with the value "myvalueabc"

cas

Check-and-Set an item; store data only if no one else has updated the item since its last fetch, determined with the cas token from the gets command. LSMCD assigns a unique 64-bit cas token to all items stored in it.

Syntax

cas <key> <flags> <TTL> <length> <cas unique key> [noreply]

Parameters

  • key - The name of the unique key by which data is accessed.
  • flags - A 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • TTL - The length of time (in seconds) the key/value pair will be stored in cache. A 0 value means the data will “never expire” and should not be removed from the cache unless required. If the TTL is more than 30 days then LSMCD interprets it as UNIX timestamp for expiration.
  • length - The length of the data in bytes that needs to be stored in LSMCD.
  • cas unique key - A unique token number obtained from gets comamand.
  • noreply - This optional parameter tells the server not to send any reply.

Example

Request

cas mykey 0 120 10 2
abcdeabcde

Response

STORED

Output Notes

  • 0: no flags
  • 120: store data for 2 minutes (120 seconds)
  • 10: data is 10 bytes long
  • 2: unique token number obtained from gets command

Possible Errors

  • ERROR: Indicates an error while saving data or the wrong syntax.
  • EXISTS: Indicates that someone has modified the CAS data since its last fetch.
  • NOT_FOUND: Indicates that the provided key does not exist in the LSMCD server.

decr

Decrement a numerical key’s value by the given number if the key/value pair exists.

Syntax

decr <key> <value> [noreply]

Parameters

  • key - The name of the unique key by which data is accessed.
  • value - The data that needs to be stored.
  • noreply - This optional parameter tells the server not to send any reply.

Example

Request

decr mykey 3
Response
2

Output Notes

  • 3: Subtract 3 from the value of "mykey". In this example, if "mykey" had a value of "5", after running decr, its value would be "2".

Possible Errors

  • NOT_FOUND: Indicates that the provided key does not exist in the LSMCD server.
  • CLIENT_ERROR: Indicates that the value associated with the provided key is not numerical.
  • ERROR: Indicates any other error such as a syntax error.

delete

Delete an existing key/value pair.

Syntax

delete <key> [noreply]

Parameters

  • noreply - This optional parameter tells the server not to send any reply.

Example

Request

delete mykey

Response

DELETED

Possible Errors

  • ERROR: Indicates incorrect syntax or an error while deleting data.
  • NOT_FOUND: Indicates that the provided key does not exist in the LSMCD server.

flush_all

Delete all key/value pairs immediately.

Syntax

flush_all [noreply]

Parameters

  • noreply - This optional parameter tells the server not to send any reply.

Example

Request

flush_all

Response

OK

get

Read the value from memory that is associated with the user-provided key.

Syntax

get <key>

Parameters

  • key - The name of the unique key by which data is accessed.

Example

Request

get mykey
Response
VALUE mykey 0 10
myvalueabc
END

Output Notes

  • 0: no flags
  • 10: data is 10 bytes long
  • myvalueabc: "mykey" is associated with the value "myvalueabc"

gets

Read the value from memory that is associated with the user-provided key as well as its cas token (to be used with the cas command).

Syntax

gets <key>

Parameters

  • key - The name of the unique key by which data is accessed.

Example

Request

gets mykey

Response

VALUE mykey 0 10 9
myvalueabc
END

Output Notes

  • 0: no flags
  • 10: data is 10 bytes long
  • 9: mykey's unique cas token number is 9

incr

Increment a numerical key’s value by the given number if the key/value pair exists.

Syntax

incr <key> <value> [noreply]

Parameters

  • key - The name of the unique key by which data is accessed.
  • value - The data that needs to be stored. This parameter needs to be given on the new line after executing the command with the above options.

Example

Request

incr mykey 4

Response

5

Output Notes

  • 4: Add 4 to the value of "mykey". In this example, if "mykey" had a value of "1", after running incr, its value would be "5".

Possible Errors

  • NOT_FOUND: Indicates that the provided key does not exist in the LSMCD server.
  • CLIENT_ERROR: Indicates that the value associated with the provided key is not numerical.
  • ERROR: Indicates any other error such as a syntax error.

prepend

Add data to an existing key before existing data.

Syntax

prepend <key> <flags> <TTL> <length> [noreply]
<value>

Parameters

  • key - The name of the unique key by which data is accessed.
  • flags - A 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • TTL - The length of time (in seconds) the key/value pair will be stored in cache. A 0 value means the data will “never expire” and should not be removed from the cache unless required. If the TTL is more than 30 days then LSMCD interprets it as UNIX timestamp for expiration.
  • length - The length of the data in bytes that needs to be stored in LSMCD.
  • noreply - This optional parameter tells the server not to send any reply.
  • value - The data that needs to be stored. This parameter needs to be given on the new line after executing the command with the above options.

Example

Request

prepend mykey 0 120 10
abcdeabcde

Response

STORED

Output Notes

  • 0: no flags
  • 120: store data for 2 minutes (120 seconds)
  • 10: add 10 bytes of data to the end of "mykey" In this example, if "mykey" had a value of "myvalueabc", after running prepend, its value would be "abcdeabcdemyvalueabc".

!!! failure "Possible Errors"** * NOT_STORED: Indicates that the key does not exist in the LSMCD server and its data could not be modified. * CLIENT_ERROR: Indicates other errors such as syntax errors.

quit

Terminate telnet session.

Syntax

quit

Example

Request

quit

Response

Connection closed by foreign host.

replace

Store a key/value pair, but only if it already exists.

Syntax

replace <key> <flags> <TTL> <length> [noreply] 
<value>

Parameters

  • key - The name of the unique key by which data is accessed.
  • flags - A 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • TTL - The length of time (in seconds) the key/value pair will be stored in cache. A 0 value means the data will “never expire” and should not be removed from the cache unless required. If the TTL is more than 30 days then LSMCD interprets it as UNIX timestamp for expiration.
  • length - The length of the data in bytes that needs to be stored in LSMCD.
  • noreply - This optional parameter tells the server not to send any reply.
  • value - The data that needs to be stored. This parameter needs to be given on the new line after executing the command with the above options.

Example

Request

replace mykey 0 120 10
myvalueabc

Response

STORED

Output Notes

  • 0: no flags
  • 120: store data for 2 minutes (120 seconds)
  • 10: data is 10 bytes long
  • myvalueabc: "mykey" will be associated with the value "myvalueabc"

Possible Errors

  • NOT_STORED: Indicates that the provided key does not already exist in the LSMCD server so the data associated with that key could not be updated.

set

Store a key/value pair, if the key exists already, overwrite it.

Syntax

set <key> <flags> <TTL> <length> [noreply] \r\n <value> \r\n

Parameters

  • key - The name of the unique key by which data is accessed.
  • flags - A 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • TTL - The length of time (in seconds) the key/value pair will be stored in cache. A 0 value means the data will “never expire” and should not be removed from the cache unless required. If the TTL is more than 30 days then LSMCD interprets it as UNIX timestamp for expiration.
  • length - The length of the data in bytes that needs to be stored in LSMCD.
  • noreply - This optional parameter tells the server not to send any reply.
  • value - The data that needs to be stored. This parameter needs to be given on the new line after executing the command with the above options.

Example

Request

set mykey 0 120 10
myvalueabc

Response

STORED

Output Notes

  • 0: no flags
  • 120: store data for 2 minutes (120 seconds)
  • 10: data is 10 bytes long
  • myvalueabc: “newkey” will be associated with the value “myvalueabc”

Possible Errors

  • ERROR: Indicates incorrect syntax or an error while saving.

stats

Print or reset general statistics.

Syntax

stats [reset]

Parameters

  • reset - If this optional parameter is used, LSMCD flushes its stored general statistics data instead of outputting it to the screen.

Example

Request

stats

Response

STAT pid 16825
STAT version 1.0.0
STAT pointer_size 64
STAT rusage_user 0.300000
STAT rusage_system 0.520000
STAT cmd_get 10
STAT cmd_set 11
STAT cmd_flush 2
STAT cmd_touch 2
STAT get_hits 8
STAT get_misses 2
STAT delete_misses 0
STAT delete_hits 1
STAT incr_misses 0
STAT incr_hits 1
STAT decr_misses 1
STAT decr_hits 1
STAT cas_misses 0
STAT cas_hits 1
STAT cas_badval 0
STAT touch_hits 2
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
END

Example

Request

stats reset

Response

RESET

touch

Update the expiration time for a key/value pair without fetching it.

Syntax

touch <key> <TTL> [noreply]

Parameters

  • key - The name of the unique key by which data is accessed.
  • TTL - The length of time (in seconds) the key/value pair will be stored in cache. A 0 value means the data will “never expire” and should not be removed from the cache unless required. If the TTL is more than 30 days then LSMCD interprets it as UNIX timestamp for expiration.
  • noreply - This optional parameter tells the server not to send any reply.

Example

Request

touch mykey 1200

Response

TOUCHED

Output Notes

  • 1200: set "mykey" to be stored for 20 minutes (1200 seconds) from the moment the touch command is run.

verbosity

Change the verbosity level of the output of LSMCD.

Syntax

verbosity <level> [noreply]

Parameters

  • level - Tells LSMCD to print output at a certain level of detail, this value should be between 1 and 3. Will always output OK.
  • noreply - This optional parameter tells the server not to send any reply.

Example

Request

verbosity 1

Response

OK

version

Print LSMCD server API version. This is not the version of the code but the version of the API.

Syntax

version

Example

Request

version

Response

VERSION 1.0.0


Last update: April 27, 2020