redis-collections


Nameredis-collections JSON
Version 0.13.0 PyPI version JSON
download
home_pagehttps://github.com/redis-collections/redis-collections
SummarySet of basic Python collections backed by Redis.
upload_time2024-03-27 15:00:09
maintainerNone
docs_urlhttps://pythonhosted.org/redis-collections/
authorHonza Javorek
requires_python>=3.8
licenseISC
keywords redis persistence
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            
Redis Collections
=================

`redis-collections` is a Python library that provides a high-level
interface to `Redis <http://redis.io/>`_, the excellent key-value store.

As of 2024, this project is retired. This repository will remain available as
a public archive.

Quickstart
----------

Import the collections from the top-level ``redis_collections`` package.

Standard collections
^^^^^^^^^^^^^^^^^^^^

The standard collections (e.g. ``Dict``, ``List``, ``Set``) behave like their
Python counterparts:

.. code-block:: python

    >>> from redis_collections import Dict, List, Set

    >>> D = Dict()
    >>> D['answer'] = 42
    >>> D['answer']
    42

+---------------------+------------+------------------------------------------------------+
|  Collection         | Redis type | Description                                          |
+=====================+============+======================================================+
| ``Dict``            | Hash       | Emulates Python's ``dict``                           |
+---------------------+------------+------------------------------------------------------+
| ``List``            | List       | Emulates Python's ``list``                           |
+---------------------+------------+------------------------------------------------------+
| ``Set``             | Set        | Emulates Python's ``set``                            |
+---------------------+------------+------------------------------------------------------+
| ``Counter``         | Hash       | Emulates Python's ``collections.Counter``            |
+---------------------+------------+------------------------------------------------------+
| ``DefaultDict``     | Hash       | Emulates Python's ``collections.defaultdict``        |
+---------------------+------------+------------------------------------------------------+
| ``Deque``           | List       | Emulates Python's ``collections.deque``              |
+---------------------+------------+------------------------------------------------------+

Syncable collections
^^^^^^^^^^^^^^^^^^^^

The syncable collections in this package provide types whose
contents are kept in memory. When their ``sync`` method is called those
contents are written to Redis:

.. code-block:: python

    >>> from redis_collections import SyncableDict

    >>> with SyncableDict() as D:
    ...     D['a'] = 1  # No write to Redis
    ...     D['a'] += 1  # No read from or write to Redis
    >>> D['a']  # D.sync() is called at the end of the with block
    2

+-------------------------+-----------------------------+-----------------------+
| Collection              | Python type                 | Description           |
+=========================+=============================+=======================+
| ``SyncableDict``        | ``dict``                    | Syncs to a Redis Hash |
+-------------------------+-----------------------------+-----------------------+
| ``SyncableList``        | ``list``                    | Syncs to a Redis List |
+-------------------------+-----------------------------+-----------------------+
| ``SyncableSet``         | ``set``                     | Syncs to a Redis Set  |
+-------------------------+-----------------------------+-----------------------+
| ``SyncableCounter``     | ``collections.Counter``     | Syncs to a Redis Hash |
+-------------------------+-----------------------------+-----------------------+
| ``SyncableDeque``       | ``collections.deque``       | Syncs to a Redis List |
+-------------------------+-----------------------------+-----------------------+
| ``SyncableDefaultDict`` | ``collections.defaultdict`` | Syncs to a Redis Hash |
+-------------------------+-----------------------------+-----------------------+

Other collections
^^^^^^^^^^^^^^^^^

The ``LRUDict`` collection stores recently used items in in memory.
It pushes older items to Redis:

.. code-block:: python

    >>> from redis_collections import LRUDict

    >>> D = LRUDict(maxsize=2)
    >>> D['a'] = 1
    >>> D['b'] = 2
    >>> D['c'] = 2  # 'a' is pushed to Redis and 'c' is stored locally
    >>> D['a']  # 'b' is pushed to Redis and 'a' is retrieved for local storage
    1
    >>> D.sync()  # All items are copied to Redis

The ``SortedSetCounter`` provides access to the Redis
`Sorted Set <http://redis.io/topics/data-types#sorted-sets>`_ type:

.. code-block:: python

    >>> from redis_collections import SortedSetCounter

    >>> ssc = SortedSetCounter([('earth', 300), ('mercury', 100)])
    >>> ssc.set_score('venus', 200)
    >>> ssc.get_score('venus')
    200.0
    >>> ssc.items()
    [('mercury', 100.0), ('venus', 200.0), ('earth', 300.0)]

Documentation
-------------

For more information, see
`redis-collections.readthedocs.io <https://redis-collections.readthedocs.io/>`_

License: ISC
------------

© 2016-2024 Bo Bayles <bbayles@gmail.com> and contributors
© 2013-2016 Honza Javorek <mail@honzajavorek.cz> and contributors

This work is licensed under `ISC license <https://en.wikipedia.org/wiki/ISC_license>`_.

This library is not affiliated with `Redis Labs <https://redislabs.com/>`__, `Redis <https://redis.io/>`__, or `redis-py <https://github.com/andymccurdy/redis-py>`__. Govern yourself accordingly!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/redis-collections/redis-collections",
    "name": "redis-collections",
    "maintainer": null,
    "docs_url": "https://pythonhosted.org/redis-collections/",
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "redis, persistence",
    "author": "Honza Javorek",
    "author_email": "mail@honzajavorek.cz",
    "download_url": "https://files.pythonhosted.org/packages/a0/2f/1dca17c29a7965459ff360a07e86b3aaf78f4b94ae4de746a8727bfb47d6/redis-collections-0.13.0.tar.gz",
    "platform": null,
    "description": "\nRedis Collections\n=================\n\n`redis-collections` is a Python library that provides a high-level\ninterface to `Redis <http://redis.io/>`_, the excellent key-value store.\n\nAs of 2024, this project is retired. This repository will remain available as\na public archive.\n\nQuickstart\n----------\n\nImport the collections from the top-level ``redis_collections`` package.\n\nStandard collections\n^^^^^^^^^^^^^^^^^^^^\n\nThe standard collections (e.g. ``Dict``, ``List``, ``Set``) behave like their\nPython counterparts:\n\n.. code-block:: python\n\n    >>> from redis_collections import Dict, List, Set\n\n    >>> D = Dict()\n    >>> D['answer'] = 42\n    >>> D['answer']\n    42\n\n+---------------------+------------+------------------------------------------------------+\n|  Collection         | Redis type | Description                                          |\n+=====================+============+======================================================+\n| ``Dict``            | Hash       | Emulates Python's ``dict``                           |\n+---------------------+------------+------------------------------------------------------+\n| ``List``            | List       | Emulates Python's ``list``                           |\n+---------------------+------------+------------------------------------------------------+\n| ``Set``             | Set        | Emulates Python's ``set``                            |\n+---------------------+------------+------------------------------------------------------+\n| ``Counter``         | Hash       | Emulates Python's ``collections.Counter``            |\n+---------------------+------------+------------------------------------------------------+\n| ``DefaultDict``     | Hash       | Emulates Python's ``collections.defaultdict``        |\n+---------------------+------------+------------------------------------------------------+\n| ``Deque``           | List       | Emulates Python's ``collections.deque``              |\n+---------------------+------------+------------------------------------------------------+\n\nSyncable collections\n^^^^^^^^^^^^^^^^^^^^\n\nThe syncable collections in this package provide types whose\ncontents are kept in memory. When their ``sync`` method is called those\ncontents are written to Redis:\n\n.. code-block:: python\n\n    >>> from redis_collections import SyncableDict\n\n    >>> with SyncableDict() as D:\n    ...     D['a'] = 1  # No write to Redis\n    ...     D['a'] += 1  # No read from or write to Redis\n    >>> D['a']  # D.sync() is called at the end of the with block\n    2\n\n+-------------------------+-----------------------------+-----------------------+\n| Collection              | Python type                 | Description           |\n+=========================+=============================+=======================+\n| ``SyncableDict``        | ``dict``                    | Syncs to a Redis Hash |\n+-------------------------+-----------------------------+-----------------------+\n| ``SyncableList``        | ``list``                    | Syncs to a Redis List |\n+-------------------------+-----------------------------+-----------------------+\n| ``SyncableSet``         | ``set``                     | Syncs to a Redis Set  |\n+-------------------------+-----------------------------+-----------------------+\n| ``SyncableCounter``     | ``collections.Counter``     | Syncs to a Redis Hash |\n+-------------------------+-----------------------------+-----------------------+\n| ``SyncableDeque``       | ``collections.deque``       | Syncs to a Redis List |\n+-------------------------+-----------------------------+-----------------------+\n| ``SyncableDefaultDict`` | ``collections.defaultdict`` | Syncs to a Redis Hash |\n+-------------------------+-----------------------------+-----------------------+\n\nOther collections\n^^^^^^^^^^^^^^^^^\n\nThe ``LRUDict`` collection stores recently used items in in memory.\nIt pushes older items to Redis:\n\n.. code-block:: python\n\n    >>> from redis_collections import LRUDict\n\n    >>> D = LRUDict(maxsize=2)\n    >>> D['a'] = 1\n    >>> D['b'] = 2\n    >>> D['c'] = 2  # 'a' is pushed to Redis and 'c' is stored locally\n    >>> D['a']  # 'b' is pushed to Redis and 'a' is retrieved for local storage\n    1\n    >>> D.sync()  # All items are copied to Redis\n\nThe ``SortedSetCounter`` provides access to the Redis\n`Sorted Set <http://redis.io/topics/data-types#sorted-sets>`_ type:\n\n.. code-block:: python\n\n    >>> from redis_collections import SortedSetCounter\n\n    >>> ssc = SortedSetCounter([('earth', 300), ('mercury', 100)])\n    >>> ssc.set_score('venus', 200)\n    >>> ssc.get_score('venus')\n    200.0\n    >>> ssc.items()\n    [('mercury', 100.0), ('venus', 200.0), ('earth', 300.0)]\n\nDocumentation\n-------------\n\nFor more information, see\n`redis-collections.readthedocs.io <https://redis-collections.readthedocs.io/>`_\n\nLicense: ISC\n------------\n\n\u00a9 2016-2024 Bo Bayles <bbayles@gmail.com> and contributors\n\u00a9 2013-2016 Honza Javorek <mail@honzajavorek.cz> and contributors\n\nThis work is licensed under `ISC license <https://en.wikipedia.org/wiki/ISC_license>`_.\n\nThis library is not affiliated with `Redis Labs <https://redislabs.com/>`__, `Redis <https://redis.io/>`__, or `redis-py <https://github.com/andymccurdy/redis-py>`__. Govern yourself accordingly!\n",
    "bugtrack_url": null,
    "license": "ISC",
    "summary": "Set of basic Python collections backed by Redis.",
    "version": "0.13.0",
    "project_urls": {
        "Homepage": "https://github.com/redis-collections/redis-collections"
    },
    "split_keywords": [
        "redis",
        " persistence"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "82d4d1eb9a22fe763d6b04df4002a37643974efb3ceea6326adba4ce45ecfeaf",
                "md5": "ff284e5e2dc0c25219a57cf9904c169d",
                "sha256": "a7c41ff0a1135004f3dec98bedabf89592746fe0a2ca4a6ee455fc3cc12f9060"
            },
            "downloads": -1,
            "filename": "redis_collections-0.13.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ff284e5e2dc0c25219a57cf9904c169d",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 29884,
            "upload_time": "2024-03-27T15:00:06",
            "upload_time_iso_8601": "2024-03-27T15:00:06.918490Z",
            "url": "https://files.pythonhosted.org/packages/82/d4/d1eb9a22fe763d6b04df4002a37643974efb3ceea6326adba4ce45ecfeaf/redis_collections-0.13.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a02f1dca17c29a7965459ff360a07e86b3aaf78f4b94ae4de746a8727bfb47d6",
                "md5": "255aeaa4b196542057ee8abd25b9206a",
                "sha256": "3ac7824e73b2aa47aee9999b73d90ca61d85b59572998b7c6c885da0047c9056"
            },
            "downloads": -1,
            "filename": "redis-collections-0.13.0.tar.gz",
            "has_sig": false,
            "md5_digest": "255aeaa4b196542057ee8abd25b9206a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 41030,
            "upload_time": "2024-03-27T15:00:09",
            "upload_time_iso_8601": "2024-03-27T15:00:09.303275Z",
            "url": "https://files.pythonhosted.org/packages/a0/2f/1dca17c29a7965459ff360a07e86b3aaf78f4b94ae4de746a8727bfb47d6/redis-collections-0.13.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-27 15:00:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "redis-collections",
    "github_project": "redis-collections",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "redis-collections"
}
        
Elapsed time: 3.45681s