This is an old revision of the document!


Interacting with LSMCD

In order to connect to and interact with LSMCD, you can use telnet to connect to a one of the IP addresses and port numbers set in Cached.Addr. For example, with the default settings, you would connect using the following command:

telnet 127.0.0.1 11211

LSMCD Commands

The following is a list of LSMCD commands useable in telnet, each with a description, an example use (including user input and system output), syntax, and an explanation of potentially confusing values. Note: for syntax, < and > indicate a required value while [ and ] indicate an optional one.

Read a value.

syntax:

get <key>

example:

get mykey

VALUE mykey 0 10
myvalueabc
END

notes:

  • 0 → no flags
  • 10 → Size in bytes
  • myvalueabc → value of “mykey”

Binary get.

syntax:

bget <key>

example:

bget mykey

VALUE mykey 0 10
1011101010
END

output notes:

  • 0 → no flags
  • 10 → Size in bytes
  • myvalueabc → value of “mykey”

Read a value and its cas token (to be used with the cas command).

syntax:

gets <key>

example:

gets mykey

VALUE mykey 0 10 9
myvalueabc
END

output notes:

  • 0 → no flags
  • 10 → Size in bytes
  • 9 → unique cas token number

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] \r\n <value> \r\n

example:

add newkey 0 120 10

output:

myvalueabc
	STORED

output notes:

  • 0 → no flags
  • 120 → TTL in seconds
  • 10 → Size in bytes
  • myvalueabc → value to set “newkey” to

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

syntax:

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

example:

set mykey 0 120 10

output:

myvalueabc
	STORED

output notes:

  • 0 → no flags
  • 120 → TTL in seconds
  • 10 → Size in bytes
  • myvalueabc → value to set “mykey” to

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

syntax:

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

example:

replace mykey 0 120 10

output:

myvalueabc
	STORED

output notes:

  • 0 → no flags
  • 120 → TTL in seconds
  • 10 → Size in bytes
  • myvalueabc → value to set “mykey” to

Add data to an existing key after existing data.

syntax:

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

example:

append mykey 0 120 10

output:

defghijklm
	STORED

output notes:

  • 0 → no flags
  • 120 → TTL in seconds
  • 10 → Size to append in bytes
  • In this example, if “mykey” had a value of “myvalueabc”, after running append, its value would be “myvalueabcdefghijklm”.

Add data to an existing key before existing data.

syntax:

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

example:

prepend mykey 0 120 10

output:

abcdeabcde
	STORED

output notes:

  • 0 → no flags
  • 120 → TTL in seconds
  • 10 → Size to prepend in bytes
  • In this example, if “mykey” had a value of “myvalueabc”, after running prepend, its value would be “abcdeabcdemyvalueabc”.

Check-and-Set an item; store data only if no one else has updated since the last fetch, determined with the cas token from the gets command.

syntax:

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

example:

cas mykey 0 120 10 2

output:

abcdeabcde
	STORED

output notes:

  • 0 → no flags
  • 120 → TTL in seconds
  • 10 → Size in bytes
  • 2 → unique token number obtained from gets command

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

syntax:

incr <key> <value> [noreply]

example:

incr mykey 4

output:

5

output notes:

  • 4 → value to increment by
    • In this example, if “mykey” had a value of “1”, after running incr, its value would be “5”.

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

syntax:

decr <key> <value> [noreply]

example:

decr mykey 3

output:

2

output notes:

  • 3 → value to decrement by.
  • In this example, if “mykey” had a value of “5”, after running decr, its value would be “2”.

Delete an existing key/value pair.

syntax:

delete <key> [<time>] [noreply]

example:

delete mykey

output:

DELETED

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

syntax:

touch <key> <TTL> [noreply]

example:

touch mykey 1200

output:

TOUCHED

output notes:

  • 1200 → new TTL in seconds

Print or reset general statistics

syntax:

stats [reset]

example:

stats

output:

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:

stats reset

output:

RESET

Delete all key/value pairs immediately.

syntax:

flush_all [<time>] [noreply]

example:

flush_all

output:

OK

Print server version.

syntax:

version

example:

version

output:

VERSION 1.0.0

Terminate telnet session.

syntax:

quit

example:

quit

output:

Connection closed by foreign host.

Increase log version.

syntax:

verbosity <level> [noreply]

example:

verbosity 1

output:

OK
  • Admin
  • Last modified: 2016/04/06 19:20
  • by Rob Holda