====== 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.
===== get =====
Read a value.
**syntax:**
get
**example:**
get mykey
VALUE mykey 0 10
myvalueabc
END
**notes:**
* **0** → no flags
* **10** → Size in bytes
* **myvalueabc** → value of "mykey"
===== bget =====
Binary get.
**syntax:**
bget
**example:**
bget mykey
**output:**
VALUE mykey 0 10
myvalueabc
END
**output notes:**
* **0** → no flags
* **10** → Size in bytes
* **myvalueabc** → value of "mykey"
===== gets =====
Read a value and its **cas token** (to be used with the **cas** command).
**syntax:**
gets
**example:**
gets mykey
**output:**
VALUE mykey 0 10 9
myvalueabc
END
**output notes:**
* **0** → no flags
* **10** → Size in bytes
* **9** → unique **cas token** number
===== add =====
Add a new key/value pair, but only if the server doesn’t already hold data for this key.
**syntax:**
add [noreply] \r\n \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
===== set =====
Store a key/value pair, if the key exists already, overwrite it.
**syntax:**
set [noreply] \r\n \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
===== replace =====
Store a key/value pair, but only if it already exists.
**syntax:**
replace [noreply] \r\n \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
===== append =====
Add data to an existing key after existing data.
**syntax:**
append [noreply] \r\n \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".
===== prepend =====
Add data to an existing key before existing data.
**syntax:**
prepend [noreply] \r\n \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".
===== cas =====
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 [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
===== incr =====
Increment numerical key’s value by the given number if the key/value pair exists.
**syntax:**
incr [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".
===== decr =====
Decrement numerical key’s value by the given number if the key/value pair exists.
**syntax:**
decr [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 =====
Delete an existing key/value pair.
**syntax:**
delete [
**example:**
delete mykey
**output:**
DELETED
===== touch =====
Update the expiration time for a key/value pair without fetching it.
**syntax:**
touch [noreply]
**example:**
touch mykey 1200
**output:**
TOUCHED
**output notes:**
* **1200** → new TTL in seconds
===== stats =====
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
===== flush_all =====
Delete all key/value pairs immediately.
**syntax:**
flush_all [
**example:**
flush_all
**output:**
OK
===== version =====
Print server version.
**syntax:**
version
**example:**
version
**output:**
VERSION 1.0.0
===== quit =====
Terminate telnet session.
**syntax:**
quit
**example:**
quit
**output:**
Connection closed by foreign host.
===== verbosity =====
Increase log version.
**syntax:**
verbosity [noreply]
**example:**
verbosity 1
**output:**
OK