python-memcached的替代品,使用ultramemcache作为接口而不是python套接字。
项目描述
Travis测试状态: [](https://travis-ci.org/nicholasserra/python-ultramemcached)
#概述
A drop in replacement for python-memcached to use [ultramemcache](https://github.com/esnme/ultramemcache) as an interface instead of python sockets. Requires ultramemcache. Usage is the same as [python-memcached](http://www.tummy.com/Community/software/python-memcached/) .
#安装
通过pip安装。
```
pip install python-ultramemcached
```
#使用
```python
import ultramemcache
mc = ultramemcache.Client(['127.0.0.1:11211'], debug=0)
mc.set("some_key", "Some value")
value = mc.get("some_key")
mc.set("another_key", 3)
mc.delete("another_key")
mc.set("key", "1") # note that the key used for incr/decr must be a string.
mc.incr("key")
mc.decr("key")
````
#与Django一起使用
要使用此包与Django一起使用,像这样实现Django的`BaseMemcachedCache`后端的子类
```python
from django.core.cache.backends.memcached import BaseMemcachedCache
class UltraMemcachedCache(BaseMemcachedCache)
"An implementation of a cache binding using python-ultramemcached"
def __init__(self, server, params)
import ultramemcache
super(MemcachedCache, self).__init__(server, params,
library=ultramemcache,
value_not_found_exception=ValueError)
```
#概述
A drop in replacement for python-memcached to use [ultramemcache](https://github.com/esnme/ultramemcache) as an interface instead of python sockets. Requires ultramemcache. Usage is the same as [python-memcached](http://www.tummy.com/Community/software/python-memcached/) .
#安装
通过pip安装。
```
pip install python-ultramemcached
```
#使用
```python
import ultramemcache
mc = ultramemcache.Client(['127.0.0.1:11211'], debug=0)
mc.set("some_key", "Some value")
value = mc.get("some_key")
mc.set("another_key", 3)
mc.delete("another_key")
mc.set("key", "1") # note that the key used for incr/decr must be a string.
mc.incr("key")
mc.decr("key")
````
#与Django一起使用
要使用此包与Django一起使用,像这样实现Django的`BaseMemcachedCache`后端的子类
```python
from django.core.cache.backends.memcached import BaseMemcachedCache
class UltraMemcachedCache(BaseMemcachedCache)
"An implementation of a cache binding using python-ultramemcached"
def __init__(self, server, params)
import ultramemcache
super(MemcachedCache, self).__init__(server, params,
library=ultramemcache,
value_not_found_exception=ValueError)
```
项目详情
关闭
python-ultramemcached-0.0.4.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | bfae69ce29f1176610061325af1fdb74983e5dbefd0c8f6b1f5a94bf907244b4 |
|
MD5 | aca43d769a4aa120fade15ca9477fe0a |
|
BLAKE2b-256 | 27b809587406a2650708becf23d4c4080f395b59f333d93229bfa0dea7d494f6 |