Tuesday, 23 August 2016

Memcached: set command

‘set’ command is used to set value to a key. Following is the syntax of set command.

Syntax
set key flags exptime bytes [noreply] value

Following table summarizes the arguments of set command.

Argument
Description
key
Name of the key.
flags
It is 32-bit unsigned integer, stored along with the data in the server and retrieved when you get the <key value> pair.
exptime
Expiry time of the data stored in cache. It is represented in seconds.
bytes
length of the data in bytes that needs to be stored in Memcached.
noreply
It is optional, when you pass this parameter, server don’t send any reply back to you.
value
Value to be stored in Memcached server.

Open new terminal and use telnet to connect to memcached server.
telnet <hostname> <port>


By default memcached server listen on port 11211.
$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.


Once you connected to server, you can able to perform all CRUD operations.
$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
set harikrishna 0 900 11
memcached

STORED
get harikrishna
VALUE harikrishna 0 11
memcached

END




Previous                                                 Next                                                 Home

No comments:

Post a Comment