{"id":28368166,"url":"https://github.com/hbnetwork/dcache","last_synced_at":"2025-12-14T00:57:50.167Z","repository":{"id":50413306,"uuid":"518258226","full_name":"HBNetwork/dcache","owner":"HBNetwork","description":null,"archived":true,"fork":false,"pushed_at":"2023-03-06T14:21:19.000Z","size":43,"stargazers_count":2,"open_issues_count":12,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-16T08:06:21.212Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HBNetwork.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-27T00:35:21.000Z","updated_at":"2025-05-20T15:07:50.000Z","dependencies_parsed_at":"2023-02-17T05:45:52.121Z","dependency_job_id":null,"html_url":"https://github.com/HBNetwork/dcache","commit_stats":null,"previous_names":["hbn3tw0rk/dcache"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/HBNetwork/dcache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HBNetwork%2Fdcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HBNetwork%2Fdcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HBNetwork%2Fdcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HBNetwork%2Fdcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HBNetwork","download_url":"https://codeload.github.com/HBNetwork/dcache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HBNetwork%2Fdcache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264958195,"owners_count":23689011,"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":[],"created_at":"2025-05-29T04:08:40.305Z","updated_at":"2025-12-14T00:57:50.054Z","avatar_url":"https://github.com/HBNetwork.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"======\ndcache\n======\n\n\n.. image:: https://img.shields.io/pypi/v/dcache.svg\n        :target: https://pypi.python.org/pypi/dcache\n        :alt: PyPI\n\n.. image:: https://coveralls.io/repos/github/HBN3tw0rk/dcache/badge.svg?branch=master\n        :target: https://coveralls.io/github/HBN3tw0rk/dcache?branch=master\n        :alt: Coverage Status\n\n.. image:: https://readthedocs.org/projects/dcache/badge/?version=latest\n        :target: https://dcache.readthedocs.io/en/latest/?version=latest\n        :alt: Documentation Status\n\nDistributed Cache for Humans\n\n\n* Documentation: https://dcache.readthedocs.io.\n\n\nInstallation\n------------\n\n.. code:: bash\n\n    pip install dcache\n\n\n\n\nHow to Use\n----------\n- TODO\n\n\nContributing\n------------\nContributions are welcome, feel free to open an Issue or Pull Request.\n\nPull requests must be for the `develop` branch.\n\n.. code:: bash\n\n    git clone https://github.com/HBN3tw0rk/dcache\n    cd dcache\n    git checkout develop\n    python -m venv .venv\n    pip install -r requirements_dev.txt\n    pre-commit install\n    pytest\n\n\nPitch (Portuguese)\n------------------\n* Part 1: https://www.loom.com/share/ee553d6915ca4dc5ba8609d48b59bd55\n* Part 2: https://www.loom.com/share/50cb4ff9560943879d78864f5fa1b4e0\n\n\nWhat is\n-------\n* distributed cache for humans\n* simple API like `lru_cache`\n* multiple backends\n* easy to switch the backend\n* good documentation\n\n\nAPI\n---\n\ndcache\n^^^^^^\n\n.. code:: python\n\n    from dcache import dcache\n\n    @dcache\n    def slow_function(n):\n        return n ** 1000\n\n\ndcache vs redis\n^^^^^^^^^^^^^^^\n\n.. code:: python\n\n    import redis\n    redis = redis.Redis(host='localhost', port=6379, db=0)\n\n    def slow_function(n):\n        cached = redis.get(n)\n        if cached:\n            return cached\n        value = n ** 1000\n        redis.set(n, value)\n        return value\n\n    def slow_function2(n):\n        cached = redis.get(n)\n        if cached:\n            return cached\n        value = n ** 1000\n        redis.set(n, value)\n        return value\n\n.. code:: python\n\n    from dcache import cache\n    from dcache.backends import RedisBackend\n\n    cache = dcache(RedisBackend(host='localhost', port=6379, db=0))\n\n    @cache\n    def slow_function(n):\n        return n ** 1000\n\n    @cache\n    def slow_function2(n):\n        return n ** 1000\n\n\nreal example\n^^^^^^^^^^^^\n\n.. code:: python\n\n    def process(id, input):\n        cache_path = get_content_cache_path(id, input)\n\n        if resource.file_exist(cache_path):\n            return resource.get_json(cache_path)\n\n        response = slow_function(id, input)\n          resource.put_json(body=response, file_path=cache_path)\n        return response\n\n.. code:: python\n\n    from dcache import dcache\n    from dcache.backends import S3Backend\n\n    @dcache(S3Backend())\n    def process(id, input):\n        return slow_function(id, input)\n\n\nIdeas\n-----\n\n* integration tests using containers\n\nmultiple backends\n^^^^^^^^^^^^^^^^^\n\n.. code:: python\n\n    from dcache import dcache\n    from dcache.backends import InMemoryBackend, RedisBackend\n\n    @dcache(multiple=[\n        InMemoryBackend(),\n        RedisBackend(host='localhost', port=6379, db=0),\n    ])\n    def slow_function(n):\n            return n ** 1000\n\n1. search on the in-memory cache;\n2. if exists, return, if not, search on Redis;\n3. * if exists on Redis, save in memory and return;\n4. * if not, exists on Redis, run the `slow_function`, save on Redis, save in-memory and return;\n\n* doesn't run if already returned\n\n\nMVP\n---\n* in memory\n\n\nRoadmap\n-------\n* backends: Redis, Memcached, Filesystem, database, S3, etc.\n* multiple backends\n* plugins\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhbnetwork%2Fdcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhbnetwork%2Fdcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhbnetwork%2Fdcache/lists"}