We store key-values all time but I belive that the time to get these values have came :). Now we will look how to get values by providing keys. The simplest syntax in memcached is get operation.
get key1 [key2] [key3]
- get is the verb of the operation.
- key1 is the key of the value we want to get
- key2,key3,… are the keys we want to get. We can get multiple values with single get.
add poftut 0 100 4 test STORED get poftut VALUE poftut 0 4 test END
As the first we add out key as we have learned before.
- get is the verb of the operation
- poftut is the key of the value
- VALUE is value options like name flag size
- test is the value we are looking for
- END means transaction is successfully ended.
Python Application
import memcache client=memcache.Client([('127.0.0.1',11211)]) samp={"poftut2":"test"} client.add("sample",samp,time=1000) print(client.get("sample"))
When executed following output is given
$ python3 get {'poftut2': 'test'}