{"id":13424702,"url":"https://github.com/comeuplater/fastapi_cache","last_synced_at":"2025-04-05T04:13:04.062Z","repository":{"id":41061334,"uuid":"282604948","full_name":"comeuplater/fastapi_cache","owner":"comeuplater","description":"FastAPI simple cache","archived":false,"fork":false,"pushed_at":"2021-09-30T07:18:28.000Z","size":84,"stargazers_count":220,"open_issues_count":9,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T03:11:20.724Z","etag":null,"topics":["cache","fastapi","python","pyton3","redis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/comeuplater.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2020-07-26T08:07:35.000Z","updated_at":"2025-03-27T16:05:33.000Z","dependencies_parsed_at":"2022-08-10T01:31:30.211Z","dependency_job_id":null,"html_url":"https://github.com/comeuplater/fastapi_cache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comeuplater%2Ffastapi_cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comeuplater%2Ffastapi_cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comeuplater%2Ffastapi_cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comeuplater%2Ffastapi_cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/comeuplater","download_url":"https://codeload.github.com/comeuplater/fastapi_cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284951,"owners_count":20913704,"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":["cache","fastapi","python","pyton3","redis"],"created_at":"2024-07-31T00:00:58.070Z","updated_at":"2025-04-05T04:13:04.020Z","avatar_url":"https://github.com/comeuplater.png","language":"Python","readme":"# FastAPI Cache\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2ec5c44e899943c8920d3c3e31616784)](https://app.codacy.com/manual/ivan.sushkov/fastapi_cache?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=comeuplater/fastapi_cache\u0026utm_campaign=Badge_Grade_Dashboard)\n[![License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n[![PyPi Version](https://img.shields.io/pypi/v/fastapi-cache.svg)](https://pypi.python.org/pypi/fastapi-cache/)\n[![Downloads](https://pepy.tech/badge/fastapi-cache)](https://pepy.tech/project/fastapi-cache)\n[![Build Status](https://travis-ci.com/comeuplater/fastapi_cache.svg?branch=master)](https://travis-ci.com/comeuplater/fastapi_cache)\n\nImplements simple lightweight cache system as dependencies in FastAPI.\n\n## Installation\n\n```sh\npip install fastapi-cache\n```\n\n## Usage example\n```python\nfrom fastapi import Depends, FastAPI\n\nfrom fastapi_cache import caches, close_caches\nfrom fastapi_cache.backends.redis import CACHE_KEY, RedisCacheBackend\n\napp = FastAPI()\n\n\ndef redis_cache():\n    return caches.get(CACHE_KEY)\n\n\n@app.get('/')\nasync def hello(\n    cache: RedisCacheBackend = Depends(redis_cache)\n):\n    in_cache = await cache.get('some_cached_key')\n    if not in_cache:\n        await cache.set('some_cached_key', 'new_value', 5)\n\n    return {'response': in_cache or 'default'}\n\n\n@app.on_event('startup')\nasync def on_startup() -\u003e None:\n    rc = RedisCacheBackend('redis://redis')\n    caches.set(CACHE_KEY, rc)\n\n\n@app.on_event('shutdown')\nasync def on_shutdown() -\u003e None:\n    await close_caches()\n```\n\n## TODO\n\n*  [X] Add tests\n*  [ ] ~~Add registry decorator~~\n*  [ ] Add dependency for requests caching\n\n## Acknowledgments\n\n* [Balburdia](https://github.com/Balburdia)\n* [xobtoor](https://github.com/xobtoor)\n* [jersobh](https://github.com/jersobh)\n\n\n## Changelog\n\n* 0.0.6 Added typings for backends. Specific arguments now need to be passed through **kwargs.\nSet default encoding to utf-8 for redis backend, removed default TTL for redis keys.\n  \n* 0.1.0 Added TTL support for InMemoryCacheBackend. Added `expire()` method that update ttl value for key.","funding_links":[],"categories":["Third-Party Extensions","Caching"],"sub_categories":["Utils"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomeuplater%2Ffastapi_cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomeuplater%2Ffastapi_cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomeuplater%2Ffastapi_cache/lists"}