Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shared-memory-dict-0.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

shared_memory_dict-0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file shared-memory-dict-0.1.1.tar.gz.

File metadata

  • Download URL: shared-memory-dict-0.1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/5.3.0-1034-azure

File hashes

Hashes for shared-memory-dict-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1bf4162b0243d1db976d2146947ef7b93a22367ef60193d2fc1f0dd232263d82
MD5 e238f0bf7587007efc0e8920f79fdf85
BLAKE2b-256 91adb4b908163259d3d47d7a5272a598a96e7cf24fe140f43d8ea7e5eb2649d8

See more details on using hashes here.

File details

Details for the file shared_memory_dict-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: shared_memory_dict-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/5.3.0-1034-azure

File hashes

Hashes for shared_memory_dict-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 075660ca2243ae4952caa599d9f6ae418ff74de1ccc110b2cf074519b875d5b1
MD5 ed37a372d944cd62fa0b7251d0fdb795
BLAKE2b-256 5801da69ec6ae11e8e4c9f627c5e9e495b0f482db49b4c7505cd41c11b116743

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page