AioMemcached
A pure-Python(3.7+) zero-depend asyncio memcached client, fork from aiomcache.
| people | |
|---|---|
| Author | Nikolay Kim fafhrd91@gmail.com |
| Maintainer | Rex Zhang rex.zhang@gmail.com |
| Contributions | Nikolay Novik nickolainovik@gmail.com |
| Andrew Svetlov andrew.svetlov@gmail.com | |
| Rex Zhang rex.zhang@gmail.com | |
| Manuel Miranda manu.mirandad@gmail.com | |
| Jeong YunWon https://github.com/youknowone | |
| Thanos Lefteris https://github.com/alefteris | |
| Maarten Draijer maarten@madra.nl | |
| Michael Gorven michael@gorven.za.net |
Install
pip install -U AioMemcached
Usage
Base command examples
Code
import asyncio
import aiomemcached
async def base_command():
client = aiomemcached.Client()
print('client.version() =>', await client.version())
print('\ninit key and value:')
k1, k2, v1, v2 = b'k1', b'k2', b'1', b'v2'
print("k1, k2, v1, v2 = b'k1', b'k2', b'1', b'2'")
keys = [k1, k2]
print("keys = [k1, k2]")
print('\nget and set key:')
print('client.set(k1, v1) =>', await client.set(k1, v1))
print('client.get(k1) =>', await client.get(k1))
print('client.set(k2, v2) =>', await client.set(k2, v2))
print('client.get(k2) =>', await client.get(k2))
print('\nincr and decr value:')
print('client.incr(k1) =>', await client.incr(k1))
print('client.decr(k1) =>', await client.decr(k1))
print('\nget multi key:')
print('client.get_many(keys) =>', await client.get_many(keys))
print('client.gets_many(keys) =>', await client.gets_many(keys))
print('client.set(k2, v2) =>', await client.set(k2, v2))
print('client.gets_many(keys) =>', await client.gets_many(keys))
print('\ndelete key:')
print('client.delete(k1) =>', await client.delete(k1))
print('client.gets_many(keys) =>', await client.gets_many(keys))
print('\nappend value to key:')
print("client.append(k2, b'append') =>",
await client.append(k2, b'append'))
print('client.get(k2) =>', await client.get(k2))
print('flush memcached:')
print('client.flush_all() =>', await client.flush_all())
print('client.get_many(keys) =>', await client.get_many(keys))
return
if __name__ == '__main__':
asyncio.run(base_command())
Output
client.version() => b'1.6.9'
init key and value:
k1, k2, v1, v2 = b'k1', b'k2', b'1', b'2'
keys = [k1, k2]
get and set key:
client.set(k1, v1) => True
client.get(k1) => (b'1', {'flags': 0, 'cas': None})
client.set(k2, v2) => True
client.get(k2) => (b'v2', {'flags': 0, 'cas': None})
incr and decr value:
client.incr(k1) => 2
client.decr(k1) => 1
get multi key:
client.get_many(keys) => ({b'k1': b'1', b'k2': b'v2'}, {b'k1': {'flags': 0, 'cas': None}, b'k2': {'flags': 0, 'cas': None}})
client.gets_many(keys) => ({b'k1': b'1', b'k2': b'v2'}, {b'k1': {'flags': 0, 'cas': 168}, b'k2': {'flags': 0, 'cas': 166}})
client.set(k2, v2) => True
client.gets_many(keys) => ({b'k1': b'1', b'k2': b'v2'}, {b'k1': {'flags': 0, 'cas': 168}, b'k2': {'flags': 0, 'cas': 169}})
delete key:
client.delete(k1) => True
client.gets_many(keys) => ({b'k2': b'v2'}, {b'k2': {'flags': 0, 'cas': 169}})
append value to key:
client.append(k2, b'append') => True
client.get(k2) => (b'v2append', {'flags': 0, 'cas': None})
flush memcached:
client.flush_all() => True
client.get_many(keys) => ({}, {})
Development
Unit test and coverage report
python -m pytest
Release files for AioMemcached 0.8.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| AioMemcached-0.8.4.tar.gz | 13.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| AioMemcached-0.8.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 26.3 kB
Release files / AioMemcached-0.8.4.tar.gz
| Download URL | AioMemcached-0.8.4.tar.gz |
|---|---|
| Size | 13.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ceda4f86256499bfd7fd609f685d52f77ec47ce9185ae0ed152f76a2e6f0ba1
|
|
BLAKE2b-256 checksum How to use checksums |
35c90f7d52b81c390b6e6ea074af731b14e466a765a80689f306ffda33f91372
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Release files / AioMemcached-0.8.4-py2.py3-none-any.whl
| Download URL | AioMemcached-0.8.4-py2.py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f76c5ac18a9232c933f497e4a2a1d0909835e18d34b8b2abc666f2952a648d87
|
|
BLAKE2b-256 checksum How to use checksums |
24cb1debe74f17751a0dcef4efb8dd3ff383cb7dcc126897b9ba9fae6374078d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|