Skip to main content

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

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)

Source distribution for shared-memory-dict 0.1.1
File Size Uploaded
shared-memory-dict-0.1.1.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shared-memory-dict 0.1.1
File Interpreter ABI Platform
shared_memory_dict-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / shared-memory-dict-0.1.1.tar.gz

Download URL shared-memory-dict-0.1.1.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1bf4162b0243d1db976d2146947ef7b93a22367ef60193d2fc1f0dd232263d82
BLAKE2b-256 checksum
How to use checksums
91adb4b908163259d3d47d7a5272a598a96e7cf24fe140f43d8ea7e5eb2649d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.8.5 Linux/5.3.0-1034-azure

Release files / shared_memory_dict-0.1.1-py3-none-any.whl

Download URL shared_memory_dict-0.1.1-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
075660ca2243ae4952caa599d9f6ae418ff74de1ccc110b2cf074519b875d5b1
BLAKE2b-256 checksum
How to use checksums
5801da69ec6ae11e8e4c9f627c5e9e495b0f482db49b4c7505cd41c11b116743
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.8.5 Linux/5.3.0-1034-azure

Release history Release notifications | RSS feed

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page