A pure-Python(3.7+) asyncio memcached client, fork from aiomcache.
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
AioMemcached-0.8.4.tar.gz
(13.1 kB
view details)
Built Distribution
File details
Details for the file AioMemcached-0.8.4.tar.gz
.
File metadata
- Download URL: AioMemcached-0.8.4.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ceda4f86256499bfd7fd609f685d52f77ec47ce9185ae0ed152f76a2e6f0ba1 |
|
MD5 | 380fae5d76c01354115c8073a2f0cd59 |
|
BLAKE2b-256 | 35c90f7d52b81c390b6e6ea074af731b14e466a765a80689f306ffda33f91372 |
File details
Details for the file AioMemcached-0.8.4-py2.py3-none-any.whl
.
File metadata
- Download URL: AioMemcached-0.8.4-py2.py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f76c5ac18a9232c933f497e4a2a1d0909835e18d34b8b2abc666f2952a648d87 |
|
MD5 | e62e0e76554ead9ba2fb4f6f9d0d9616 |
|
BLAKE2b-256 | 24cb1debe74f17751a0dcef4efb8dd3ff383cb7dcc126897b9ba9fae6374078d |