region-cache


Nameregion-cache JSON
Version 0.3.8 PyPI version JSON
download
home_pagehttps://github.com/jheard-tw/region_cache
SummaryRegion-based caching for Python/Flask with Redis
upload_time2023-06-16 13:53:56
maintainer
docs_urlNone
authorJefferson Heard
requires_python
licenseMIT license
keywords region_cache
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            ============
region_cache
============


.. image:: https://img.shields.io/pypi/v/region_cache.svg
        :target: https://pypi.python.org/pypi/region_cache

.. image:: https://img.shields.io/travis/jheard-tw/region_cache.svg
        :target: https://travis-ci.org/jheard-tw/region_cache

.. image:: https://readthedocs.org/projects/region-cache/badge/?version=latest
        :target: https://region-cache.readthedocs.io/en/latest/?badge=latest
        :alt: Documentation Status


.. image:: https://pyup.io/repos/github/jheard-tw/region_cache/shield.svg
     :target: https://pyup.io/repos/github/jheard-tw/region_cache/
     :alt: Updates



Region-based caching for Python/Flask with Redis


* Free software: MIT license
* Documentation: https://region-cache.readthedocs.io.


Features
--------

Region based Flask caching with Redis.

This module provides high-level nested, region-based caching with Redis. A region is a dot-separated
namespace where cache keys and values live. It is implemented as hashes in redis. Parent-child relationships
are implemented as sets. Timeouts use the EXPIRE command. All work is persisted in redis, and two regions with
the same name on two different processes or even different servers will share the same storage.

Invalidation of caches is "active", not "lazy", so caches are purged immediately upon invalidation, to solve
the problem of one process knowing about a cache invalidation and the other not. Cache writes are aggressively
pipelined and transactional, so if two processes write to the same key at the same time, results will not be
inconsistent.

The cache is written as a Flask extension, so you can use init_app with a valid flask app to initialize it.
Simply set the CACHE_REDIS_URL setting in the config.

Examples:
---------

Using the region as a context manager treats everything in the context manager as a single transaction::


    with region('abc.xyz') as r:
        x in r  # test for presence
        r[x] = 100  # get or KeyError
        x = r[x]  # set
        del r[x]  # remove

Bind to blinker signals, so the cache is purged declaratively::

    region('abc.xyz').invalidate_on(
        blinker.signal('a'),
        blinker.signal('b'),
        blinker.signal('c'),
        blinker.signal('d'),
    )


Nest regions. If you invalidate the parent region, all the children will also be invalidated. This is recursive, so
sub-sub-sub regions will be correctly invalidated as well::


    region('abc').region('xyz')  # subregion
    region('abc').invalidate()  # invalidate abc AND xyz


The default serializers is "pickle", but you can supply any serializer that exposes a loads and dumps, and individual
regions can be configured differently. Children inherit the settings of their parents.

Finally, timeouts are supported, and by default the timeout refreshes itself every time you write to the cache
See the region() function for more detail on how to configure it.

Credits
-------

This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage


=======
History
=======

0.3.7 (2021-12-13)
------------------
* Support Python 3.9+

0.1.0 (2018-05-04)
------------------

* First release on PyPI.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jheard-tw/region_cache",
    "name": "region-cache",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "region_cache",
    "author": "Jefferson Heard",
    "author_email": "jheard@teamworks.com",
    "download_url": "",
    "platform": null,
    "description": "============\nregion_cache\n============\n\n\n.. image:: https://img.shields.io/pypi/v/region_cache.svg\n        :target: https://pypi.python.org/pypi/region_cache\n\n.. image:: https://img.shields.io/travis/jheard-tw/region_cache.svg\n        :target: https://travis-ci.org/jheard-tw/region_cache\n\n.. image:: https://readthedocs.org/projects/region-cache/badge/?version=latest\n        :target: https://region-cache.readthedocs.io/en/latest/?badge=latest\n        :alt: Documentation Status\n\n\n.. image:: https://pyup.io/repos/github/jheard-tw/region_cache/shield.svg\n     :target: https://pyup.io/repos/github/jheard-tw/region_cache/\n     :alt: Updates\n\n\n\nRegion-based caching for Python/Flask with Redis\n\n\n* Free software: MIT license\n* Documentation: https://region-cache.readthedocs.io.\n\n\nFeatures\n--------\n\nRegion based Flask caching with Redis.\n\nThis module provides high-level nested, region-based caching with Redis. A region is a dot-separated\nnamespace where cache keys and values live. It is implemented as hashes in redis. Parent-child relationships\nare implemented as sets. Timeouts use the EXPIRE command. All work is persisted in redis, and two regions with\nthe same name on two different processes or even different servers will share the same storage.\n\nInvalidation of caches is \"active\", not \"lazy\", so caches are purged immediately upon invalidation, to solve\nthe problem of one process knowing about a cache invalidation and the other not. Cache writes are aggressively\npipelined and transactional, so if two processes write to the same key at the same time, results will not be\ninconsistent.\n\nThe cache is written as a Flask extension, so you can use init_app with a valid flask app to initialize it.\nSimply set the CACHE_REDIS_URL setting in the config.\n\nExamples:\n---------\n\nUsing the region as a context manager treats everything in the context manager as a single transaction::\n\n\n    with region('abc.xyz') as r:\n        x in r  # test for presence\n        r[x] = 100  # get or KeyError\n        x = r[x]  # set\n        del r[x]  # remove\n\nBind to blinker signals, so the cache is purged declaratively::\n\n    region('abc.xyz').invalidate_on(\n        blinker.signal('a'),\n        blinker.signal('b'),\n        blinker.signal('c'),\n        blinker.signal('d'),\n    )\n\n\nNest regions. If you invalidate the parent region, all the children will also be invalidated. This is recursive, so\nsub-sub-sub regions will be correctly invalidated as well::\n\n\n    region('abc').region('xyz')  # subregion\n    region('abc').invalidate()  # invalidate abc AND xyz\n\n\nThe default serializers is \"pickle\", but you can supply any serializer that exposes a loads and dumps, and individual\nregions can be configured differently. Children inherit the settings of their parents.\n\nFinally, timeouts are supported, and by default the timeout refreshes itself every time you write to the cache\nSee the region() function for more detail on how to configure it.\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n=======\nHistory\n=======\n\n0.3.7 (2021-12-13)\n------------------\n* Support Python 3.9+\n\n0.1.0 (2018-05-04)\n------------------\n\n* First release on PyPI.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "Region-based caching for Python/Flask with Redis",
    "version": "0.3.8",
    "project_urls": {
        "Homepage": "https://github.com/jheard-tw/region_cache"
    },
    "split_keywords": [
        "region_cache"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05aac3c65ab58d76b07ea9043b735e6df44b99a4573e4a70c5fe519227671769",
                "md5": "a5dfa083fcdf92208607b4f7ece84333",
                "sha256": "73215d0dbe3a4dffb6c764556ba50d61579133468edb99f7248e1b2f42a29dab"
            },
            "downloads": -1,
            "filename": "region_cache-0.3.8-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a5dfa083fcdf92208607b4f7ece84333",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 10350,
            "upload_time": "2023-06-16T13:53:56",
            "upload_time_iso_8601": "2023-06-16T13:53:56.073671Z",
            "url": "https://files.pythonhosted.org/packages/05/aa/c3c65ab58d76b07ea9043b735e6df44b99a4573e4a70c5fe519227671769/region_cache-0.3.8-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-16 13:53:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jheard-tw",
    "github_project": "region_cache",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "region-cache"
}
        
Elapsed time: 0.36088s