Skip to main content

In-memory cache with multiprocessing support

Project description

Introduction

UpCache is a pure Python cache with multiprocessing support.

Most Python cache frameworks require external services such as Memcached or Redis which require setup and maintenance. UpCache tries to ameliorate the process of creating a shared cache for multiprocessing workers such as those found in WSGI applications.

Getting Started

Using UpCache requires at least one instance of UpCache to remain open and available for contents to be preserved between worker processes.

Sample code provided will create a key-value pair in one process and allows another process to access it:

from multiprocessing import Process
from upcache import UpCache
import time

def worker1(name: str) -> None:
    cache = UpCache(name)
    cache.set(b'Light Entertainment Awards', b'Dickie Attenborough')
    cache.close()

def worker2(name: str) -> None:
    cache = UpCache(name)
    time.sleep(1)
    print(cache.get(b'Light Entertainment Awards'))
    cache.close()

cache_name = 'TVHosts'
p1 = Process(target=worker1, args=(cache_name,))
p2 = Process(target=worker2, args=(cache_name,))

p1.start()
p2.start()

p1.join()
p2.join()

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

upcache-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: upcache-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.3

File hashes

Hashes for upcache-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 65d22d47538e8a1231150f8ed021470b22632f6f8fa193d5be92ad8d8d21b896
MD5 11b0b1b7c5acfd6fcc649193401c4ef3
BLAKE2b-256 673d4b5bf9d0de7fb07dbb58d78d8d9665f356bca23ff6314a00c122c4df5536

See more details on using hashes here.

Supported by

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