ring

Python cache interface with clean API and built-in memcache & redis + asyncio support.

https://github.com/youknowone/ring

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 23 committers (4.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.0%) to scientific vocabulary

Keywords

aiomcache aioredis asyncio cache diskcache django lru memcache python python2 python3 redis
Last synced: 6 months ago · JSON representation

Repository

Python cache interface with clean API and built-in memcache & redis + asyncio support.

Basic Info
Statistics
  • Stars: 488
  • Watchers: 9
  • Forks: 35
  • Open Issues: 30
  • Releases: 1
Topics
aiomcache aioredis asyncio cache diskcache django lru memcache python python2 python3 redis
Created over 9 years ago · Last pushed 11 months ago
Metadata Files
Readme License

README.rst

Ring
====

.. image:: https://badges.gitter.im/ring-cache/community.svg
   :alt: Join the chat at https://gitter.im/ring-cache/community
   :target: https://gitter.im/ring-cache/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

.. image:: https://github.com/youknowone/ring/actions/workflows/python-package.yml/badge.svg
.. image:: https://codecov.io/gh/youknowone/ring/graph/badge.svg
    :target: https://codecov.io/gh/youknowone/ring

Let's concentrate on code, not on storages.

Ring shows a way to control cache in point of view of code - not about storages.
Ring's decorator is convenient but also keeps fluency for general scenarios.

asyncio support for Python3.5+!

Take advantage of perfectly explicit and fully automated cache interface.
Ring decorators convert your functions to cached version of them, with extra
control methods.


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

Full documentation with examples and references:
``_

- Function/method support.
- asyncio support.
- Django support.
- Bulk access support.


Function cache
--------------

.. code:: python

    import ring
    import memcache
    import requests

    mc = memcache.Client(['127.0.0.1:11211'])

    # working for mc, expire in 60sec
    @ring.memcache(mc, time=60)
    def get_url(url):
        return requests.get(url).content

    # normal way - it is cached
    data = get_url('http://example.com')

It is a normal smart cache flow.

But ring is different when you want to explicitly control it.


.. code:: python

    # delete the cache
    get_url.delete('http://example.com')
    # get cached data or None
    data_or_none = get_url.get('http://example.com')

    # get internal cache key
    key = get_url.key('http://example.com')
    # and access directly to the backend
    direct_data = mc.get(key)


Method cache
------------

.. code:: python

    import ring
    import redis

    rc = redis.StrictRedis()

    class User(dict):
        def __ring_key__(self):
            return self['id']

        # working for rc, no expiration
        # using json coder for non-bytes cache data
        @ring.redis(rc, coder='json')
        def data(self):
            return self.copy()

        # parameters are also ok!
        @ring.redis(rc, coder='json')
        def child(self, child_id):
            return {'user_id': self['id'], 'child_id': child_id}

    user = User(id=42, name='Ring')

    # create and get cache
    user_data = user.data()  # cached
    user['name'] = 'Ding'
    # still cached
    cached_data = user.data()
    assert user_data == cached_data
    # refresh
    updated_data = user.data.update()
    assert user_data != updated_data

    # id is the cache key so...
    user2 = User(id=42)
    # still hitting the same cache
    assert updated_data == user2.data()


Installation
------------

PyPI is the recommended way.

.. sourcecode:: shell

    $ pip install ring

To browse versions and tarballs, visit:
    ``_


To use memcached or redis, don't forget to install related libraries.
For example: python-memcached, python3-memcached, pylibmc, redis-py, Django etc

It may require to install and run related services on your system too.
Look for `memcached` and `redis` for your system.


Contributors
------------

See contributors list on:
    ``_

Owner

  • Name: Jeong, YunWon
  • Login: youknowone
  • Kind: user
  • Location: Seoul, The Republic of Korea
  • Company: youknowone.org

GitHub Events

Total
  • Issues event: 3
  • Watch event: 16
  • Delete event: 1
  • Issue comment event: 7
  • Push event: 8
  • Pull request review event: 1
  • Pull request event: 6
  • Create event: 3
Last Year
  • Issues event: 3
  • Watch event: 16
  • Delete event: 1
  • Issue comment event: 7
  • Push event: 8
  • Pull request review event: 1
  • Pull request event: 6
  • Create event: 3

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 312
  • Total Committers: 23
  • Avg Commits per committer: 13.565
  • Development Distribution Score (DDS): 0.292
Past Year
  • Commits: 4
  • Committers: 2
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.25
Top Committers
Name Email Commits
Jeong YunWon j****g@y****g 221
yunitto h****r@g****m 25
yangroro y****g@h****r 13
Geonu Lee g****o@g****m 7
Seonghyeon Kim a****a@a****s 7
Dongwon Kim d****m@n****m 6
JimJeon j****e@g****m 6
Hyunjoon y****n@g****m 5
yangroro r****e@k****z 4
xymz h****e@s****r 3
jowoojun j****n@n****m 2
weiyang w****s@g****m 2
Danil Akhtarov d****o@g****m 1
Danyla Hulchuk d****k@g****m 1
Dongwon Kim d****0@g****m 1
Dustin Rodrigues d****d@g****m 1
Seunghun Lee w****1@g****m 1
The Gitter Badger b****r@g****m 1
Vazrupe v****e@n****m 1
changgunLee c****4@g****m 1
long2ice l****e@p****m 1
Yi Hyunjoon t****k@d****u 1
유정민 m****y@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 55
  • Total pull requests: 55
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 9 days
  • Total issue authors: 24
  • Total pull request authors: 17
  • Average comments per issue: 1.05
  • Average comments per pull request: 1.91
  • Merged pull requests: 46
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 4
  • Average time to close issues: 18 days
  • Average time to close pull requests: 16 days
  • Issue authors: 2
  • Pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 1.75
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • youknowone (28)
  • striveforbest (2)
  • nonamethanks (2)
  • wy-z (2)
  • yangroro (2)
  • yodog (1)
  • elyase (1)
  • matthieudesprez (1)
  • VakarisZ (1)
  • ssnl (1)
  • dhulchuk (1)
  • chado13 (1)
  • majorgilles (1)
  • jojurajan (1)
  • isaevmik (1)
Pull Request Authors
  • youknowone (31)
  • yangroro (5)
  • geonu (3)
  • wy-z (3)
  • xymz (2)
  • yunitto (2)
  • NovemberOscar (2)
  • machenity (1)
  • dhulchuk (1)
  • ohduran (1)
  • amsukdu (1)
  • dtrodrigues (1)
  • JimJeon (1)
  • exexute (1)
  • long2ice (1)
Top Labels
Issue Labels
good first issue (9)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 23,060 last-month
  • Total docker downloads: 13
  • Total dependent packages: 2
  • Total dependent repositories: 37
  • Total versions: 28
  • Total maintainers: 1
pypi.org: ring

Function-oriented cache interface with built-in memcache & redis + asyncio support.

  • Versions: 28
  • Dependent Packages: 2
  • Dependent Repositories: 37
  • Downloads: 23,060 Last month
  • Docker Downloads: 13
Rankings
Dependent repos count: 2.4%
Downloads: 2.8%
Stargazers count: 2.9%
Dependent packages count: 3.2%
Average: 3.6%
Docker downloads count: 4.0%
Forks count: 6.4%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/python-package.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
docker-compose.yml docker
  • memcached latest
  • redis latest
docs/readthedocs-requirements.txt pypi
  • django *
setup.py pypi
  • attrs >=19.3.0
  • functools32 >=3.2.3
  • inspect2 >=0.1.0
  • six >=1.11.0
  • wirerope ==0.4.5