redis-collections


Nameredis-collections JSON
Version 0.12.0 PyPI version JSON
download
home_pagehttps://github.com/redis-collections/redis-collections
SummarySet of basic Python collections backed by Redis.
upload_time2023-08-09 14:58:21
maintainer
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.

Quickstart
----------

Install the library with ``pip install redis-collections``.
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/>`_

Maintainers
-----------

- Bo Bayles (`@bbayles <http://github.com/bbayles>`_)
- Honza Javorek (`@honzajavorek <http://github.com/honzajavorek>`_)

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

© 2016-? 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": "",
    "docs_url": "https://pythonhosted.org/redis-collections/",
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "redis,persistence",
    "author": "Honza Javorek",
    "author_email": "mail@honzajavorek.cz",
    "download_url": "https://files.pythonhosted.org/packages/cb/d5/c4f96757321074b48b1da7c7091a2d6d7095d4cc1a6cc17f33e118b9341b/redis-collections-0.12.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\nQuickstart\n----------\n\nInstall the library with ``pip install redis-collections``.\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\nMaintainers\n-----------\n\n- Bo Bayles (`@bbayles <http://github.com/bbayles>`_)\n- Honza Javorek (`@honzajavorek <http://github.com/honzajavorek>`_)\n\nLicense: ISC\n------------\n\n\u00a9 2016-? 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.12.0",
    "project_urls": {
        "Homepage": "https://github.com/redis-collections/redis-collections"
    },
    "split_keywords": [
        "redis",
        "persistence"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "176da8cd1d593e59de6f28e6ddd23a5e316a2d256ce50e3fa4f284f974ac83d1",
                "md5": "79fd5ed6ac6f875bd2ae0fa5a1e49419",
                "sha256": "a3d88762ce758eddffeb18f3717ada256be1bb19f83debbbec0fe3151db352e3"
            },
            "downloads": -1,
            "filename": "redis_collections-0.12.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "79fd5ed6ac6f875bd2ae0fa5a1e49419",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 29874,
            "upload_time": "2023-08-09T14:58:19",
            "upload_time_iso_8601": "2023-08-09T14:58:19.312361Z",
            "url": "https://files.pythonhosted.org/packages/17/6d/a8cd1d593e59de6f28e6ddd23a5e316a2d256ce50e3fa4f284f974ac83d1/redis_collections-0.12.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cbd5c4f96757321074b48b1da7c7091a2d6d7095d4cc1a6cc17f33e118b9341b",
                "md5": "f12a1e2a4112fc1613128c4e66e7fc5d",
                "sha256": "d7ccc40ddb174eef8343e85b40a33cea4b1faae5e45bdd95cb51bd7aeeba2b6e"
            },
            "downloads": -1,
            "filename": "redis-collections-0.12.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f12a1e2a4112fc1613128c4e66e7fc5d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 26716,
            "upload_time": "2023-08-09T14:58:21",
            "upload_time_iso_8601": "2023-08-09T14:58:21.087962Z",
            "url": "https://files.pythonhosted.org/packages/cb/d5/c4f96757321074b48b1da7c7091a2d6d7095d4cc1a6cc17f33e118b9341b/redis-collections-0.12.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-09 14:58:21",
    "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: 0.10453s