A very simple shared memory dict implementation
Project description
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
name
defines 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for shared_memory_dict-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24b1ee764b98f2b63c9df72a8ac5dfa65a083224ee6b5c7017fed2b12af40280 |
|
MD5 | 9b84befaf475ba9e58505a5c35c67c33 |
|
BLAKE2b-256 | 68bf4cff46eb95ae200d641d5aefb1da9d2fefb1cd939b6ef808a543363b9ea1 |