memcached获取对象_Memcached使用Python获取操作示例

memcached获取对象

memcached获取对象

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.

我们一直存储键值,但我相信获得这些值的时机已经到来了:)。 现在,我们将研究如何通过提供键来获取值。 memcached中最简单的语法是get操作。

get key1 [key2] [key3]
  • get is the verb of the operation.

    get是操作的动词。

  • key1  is the key of the value we want to get

    key1是我们要获取的值的键

  • key2,key3,… are the keys we want to get. We can get multiple values with single get.

    key2,key3,…是我们要获取的键。 我们可以一次获得多个值。

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

    get是操作的动词

  • poftut is the key of the value

    Poftut是价值的关键

  • VALUE is value options like name flag size

    VALUE是值选项,例如名称标志大小

  • test is the value we are looking for

    测试是我们正在寻找的价值

  • END means transaction is successfully ended.

    END表示事务已成功结束。

Python应用 (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'}
LEARN MORE  How to Install Pip in Debian, Ubuntu, Kali, Mint?
了解更多如何在Debian,Ubuntu,Kali,Mint中安装Pip?

翻译自: https://www.poftut.com/memcached-get-operation-python-example/

memcached获取对象

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值