Shared Memory Dict
A very simple shared memory dict implementation.
Require: Python >=3.8
>> from shared_memory_dict import SharedMemoryDict
>> smd = SharedMemoryDict(name='tokens', size=1024)
>> smd['some-key'] = 'some-value-with-any-type'
>> smd['some-key']
'some-value-with-any-type'
The arg
namedefines the location of the memory block, so if you want to share the memory between process use the same name
To use uwsgidecorators.lock on write operations of shared memory dict set environment variable SHARED_MEMORY_USE_UWSGI_LOCK.
Django Cache Implementation
There's a Django Cache Implementation with Shared Memory Dict:
# settings/base.py
CACHES = {
'default': {
'BACKEND': 'shared_memory_dict.caches.django.SharedMemoryCache',
'LOCATION': 'memory',
'OPTIONS': {'MEMORY_BLOCK_SIZE': 1024}
}
}
This implementation is very based on django LocMemCache
AioCache Backend
There's also a AioCache Backend Implementation with Shared Memory Dict:
From aiocache import caches
caches.set_config({
'default': {
'cache': 'shared_memory_dict.caches.aiocache.SharedMemoryCache',
'size': 1024,
},
})
This implementation is very based on aiocache SimpleMemoryCache
Release files for shared-memory-dict 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shared-memory-dict-0.1.1.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shared_memory_dict-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.2 kB