upcache


Nameupcache JSON
Version 0.2.5 PyPI version JSON
download
home_pagehttps://www.nuradius.com
SummaryIn-memory cache with multiprocessing support
upload_time2023-06-07 16:34:33
maintainer
docs_urlNone
authorNuradius Software
requires_python>=3.7
licenseApache Software License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# 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()

if __name__ == '__main__':
    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()
```

# Architecture

UpCache spawns an internally-hosted TCP server which facilitates inter-process
communication and provides a synchronized in-memory key-value store.

To avoid overlapping TCP servers from spawning when using UpCache, the library
creates an exclusive connection file to claim ownership as the process to spawn
the TCP server.  Once the TCP server begins running on an ephemeral port, it
writes the connection info into the connection file for all UpCache clients to
connect to the TCP server for the key-value store.

UpCache clients are typically shared per cache per process to avoid heavy
resource contention (one client equals one TCP socket).

Once all clients disconnect, the UpCache TCP server shuts down and disposes of
all contents (both the in-memory key-value store and connection file).

# Features

UpCache supports the following:
 - Basic key operations (get/set/drop, increment/decrement, clear, count, keys, items)
 - Waiting for key events
 - Subscriptions to key events



            

Raw data

            {
    "_id": null,
    "home_page": "https://www.nuradius.com",
    "name": "upcache",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Nuradius Software",
    "author_email": "todd@datacomponents.net",
    "download_url": "",
    "platform": null,
    "description": "\n# Introduction\n\nUpCache is a pure Python cache with multiprocessing support.\n\nMost Python cache frameworks require external services such as Memcached or Redis which\nrequire setup and maintenance.  UpCache tries to ameliorate the process of creating\na shared cache for multiprocessing workers such as those found in WSGI applications.\n\n# Getting Started\n\nUsing UpCache requires at least one instance of UpCache to remain open and available for\ncontents to be preserved between worker processes.\n\nSample code provided will create a key-value pair in one process and allows another\nprocess to access it:\n\n```\nfrom multiprocessing import Process\nfrom upcache import UpCache\nimport time\n\ndef worker1(name: str) -> None:\n    cache = UpCache(name)\n    cache.set(b'Light Entertainment Awards', b'Dickie Attenborough')\n    cache.close()\n\ndef worker2(name: str) -> None:\n    cache = UpCache(name)\n    time.sleep(1)\n    print(cache.get(b'Light Entertainment Awards'))\n    cache.close()\n\nif __name__ == '__main__':\n    cache_name = 'TVHosts'\n    p1 = Process(target=worker1, args=(cache_name,))\n    p2 = Process(target=worker2, args=(cache_name,))\n\n    p1.start()\n    p2.start()\n\n    p1.join()\n    p2.join()\n```\n\n# Architecture\n\nUpCache spawns an internally-hosted TCP server which facilitates inter-process\ncommunication and provides a synchronized in-memory key-value store.\n\nTo avoid overlapping TCP servers from spawning when using UpCache, the library\ncreates an exclusive connection file to claim ownership as the process to spawn\nthe TCP server.  Once the TCP server begins running on an ephemeral port, it\nwrites the connection info into the connection file for all UpCache clients to\nconnect to the TCP server for the key-value store.\n\nUpCache clients are typically shared per cache per process to avoid heavy\nresource contention (one client equals one TCP socket).\n\nOnce all clients disconnect, the UpCache TCP server shuts down and disposes of\nall contents (both the in-memory key-value store and connection file).\n\n# Features\n\nUpCache supports the following:\n - Basic key operations (get/set/drop, increment/decrement, clear, count, keys, items)\n - Waiting for key events\n - Subscriptions to key events\n\n\n",
    "bugtrack_url": null,
    "license": "Apache Software License",
    "summary": "In-memory cache with multiprocessing support",
    "version": "0.2.5",
    "project_urls": {
        "Homepage": "https://www.nuradius.com"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7fa92c5c254f966f56a1c2dd78ccf7fa941f6434d934a41a09febe79a2dbc43",
                "md5": "4dfda74b2d7d50113ea72a20fc761590",
                "sha256": "c41ae470aeb447589999ecd7ef38f81cc79d5e2dc35d4012d2f682337a09df26"
            },
            "downloads": -1,
            "filename": "upcache-0.2.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4dfda74b2d7d50113ea72a20fc761590",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 16224,
            "upload_time": "2023-06-07T16:34:33",
            "upload_time_iso_8601": "2023-06-07T16:34:33.441844Z",
            "url": "https://files.pythonhosted.org/packages/f7/fa/92c5c254f966f56a1c2dd78ccf7fa941f6434d934a41a09febe79a2dbc43/upcache-0.2.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-07 16:34:33",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "upcache"
}
        
Elapsed time: 0.07450s