{"id":13737839,"url":"https://github.com/youknowone/ring","last_synced_at":"2025-05-14T15:12:02.298Z","repository":{"id":46708046,"uuid":"65191260","full_name":"youknowone/ring","owner":"youknowone","description":"Python cache interface with clean API and built-in memcache \u0026 redis + asyncio support.","archived":false,"fork":false,"pushed_at":"2025-03-28T07:44:53.000Z","size":659,"stargazers_count":487,"open_issues_count":30,"forks_count":36,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-08T08:11:09.795Z","etag":null,"topics":["aiomcache","aioredis","asyncio","cache","diskcache","django","lru","memcache","python","python2","python3","redis"],"latest_commit_sha":null,"homepage":"http://ring-cache.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/youknowone.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-08T09:28:27.000Z","updated_at":"2025-04-04T20:36:27.000Z","dependencies_parsed_at":"2025-04-01T07:39:00.996Z","dependency_job_id":"3c13132b-522a-409f-b2ca-11c86aadcfbb","html_url":"https://github.com/youknowone/ring","commit_stats":{"total_commits":307,"total_committers":24,"mean_commits":"12.791666666666666","dds":0.3452768729641694,"last_synced_commit":"b5c34df262eb6c33115dc2b1e1bc83faa6bb42d0"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youknowone%2Fring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youknowone%2Fring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youknowone%2Fring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youknowone%2Fring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/youknowone","download_url":"https://codeload.github.com/youknowone/ring/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254170059,"owners_count":22026219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiomcache","aioredis","asyncio","cache","diskcache","django","lru","memcache","python","python2","python3","redis"],"created_at":"2024-08-03T03:02:02.805Z","updated_at":"2025-05-14T15:12:02.257Z","avatar_url":"https://github.com/youknowone.png","language":"Python","readme":"Ring\n====\n\n.. image:: https://badges.gitter.im/ring-cache/community.svg\n   :alt: Join the chat at https://gitter.im/ring-cache/community\n   :target: https://gitter.im/ring-cache/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge\n\n.. image:: https://github.com/youknowone/ring/actions/workflows/python-package.yml/badge.svg\n.. image:: https://codecov.io/gh/youknowone/ring/graph/badge.svg\n    :target: https://codecov.io/gh/youknowone/ring\n\nLet's concentrate on code, not on storages.\n\nRing shows a way to control cache in point of view of code - not about storages.\nRing's decorator is convenient but also keeps fluency for general scenarios.\n\nasyncio support for Python3.5+!\n\nTake advantage of perfectly explicit and fully automated cache interface.\nRing decorators convert your functions to cached version of them, with extra\ncontrol methods.\n\n\nDocumentation\n-------------\n\nFull documentation with examples and references:\n`\u003chttp://ring-cache.readthedocs.io/\u003e`_\n\n- Function/method support.\n- asyncio support.\n- Django support.\n- Bulk access support.\n\n\nFunction cache\n--------------\n\n.. code:: python\n\n    import ring\n    import memcache\n    import requests\n\n    mc = memcache.Client(['127.0.0.1:11211'])\n\n    # working for mc, expire in 60sec\n    @ring.memcache(mc, time=60)\n    def get_url(url):\n        return requests.get(url).content\n\n    # normal way - it is cached\n    data = get_url('http://example.com')\n\nIt is a normal smart cache flow.\n\nBut ring is different when you want to explicitly control it.\n\n\n.. code:: python\n\n    # delete the cache\n    get_url.delete('http://example.com')\n    # get cached data or None\n    data_or_none = get_url.get('http://example.com')\n\n    # get internal cache key\n    key = get_url.key('http://example.com')\n    # and access directly to the backend\n    direct_data = mc.get(key)\n\n\nMethod cache\n------------\n\n.. code:: python\n\n    import ring\n    import redis\n\n    rc = redis.StrictRedis()\n\n    class User(dict):\n        def __ring_key__(self):\n            return self['id']\n\n        # working for rc, no expiration\n        # using json coder for non-bytes cache data\n        @ring.redis(rc, coder='json')\n        def data(self):\n            return self.copy()\n\n        # parameters are also ok!\n        @ring.redis(rc, coder='json')\n        def child(self, child_id):\n            return {'user_id': self['id'], 'child_id': child_id}\n\n    user = User(id=42, name='Ring')\n\n    # create and get cache\n    user_data = user.data()  # cached\n    user['name'] = 'Ding'\n    # still cached\n    cached_data = user.data()\n    assert user_data == cached_data\n    # refresh\n    updated_data = user.data.update()\n    assert user_data != updated_data\n\n    # id is the cache key so...\n    user2 = User(id=42)\n    # still hitting the same cache\n    assert updated_data == user2.data()\n\n\nInstallation\n------------\n\nPyPI is the recommended way.\n\n.. sourcecode:: shell\n\n    $ pip install ring\n\nTo browse versions and tarballs, visit:\n    `\u003chttps://pypi.python.org/pypi/ring/\u003e`_\n\n\nTo use memcached or redis, don't forget to install related libraries.\nFor example: python-memcached, python3-memcached, pylibmc, redis-py, Django etc\n\nIt may require to install and run related services on your system too.\nLook for `memcached` and `redis` for your system.\n\n\nContributors\n------------\n\nSee contributors list on:\n    `\u003chttps://github.com/youknowone/ring/graphs/contributors\u003e`_\n\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyouknowone%2Fring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyouknowone%2Fring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyouknowone%2Fring/lists"}