# CachiPy: A Caching Library for FastAPI
CachiPy is a caching library specially designed for use with FastAPI. It allows you to easily cache API responses and improve the performance of your FastAPI applications.
![CachiPy Logo](https://raw.githubusercontent.com/Ambar-06/CachiPy/main/CachiPy/CachiPy.png)
## Features
- Simple and efficient caching for FastAPI applications.
- Support for caching API responses and function results.
- Easy integration with FastAPI routes.
- Customizable cache size and eviction policies.
- Automatic cache clearing.
## Installation
You can install CachiPy using pip:
```bash
pip install CachiPy
```
## Usage
```python
from fastapi import FastAPI
from CachiPy import cacheit
import time
app = FastAPI()
@cacheit
def factorial(n):
if n <= 1:
return 1
else:
return n * factorial(n - 1)
# ... define FastAPI routes and route handlers ...
# Use @cacheit decorator to cache results within your route handlers.
```
Example usage:
```python
@app.get("/factorial/{n}")
def calculate_factorial(n: int):
result = factorial(n)
return {
"result": result,
"execution_time": end_time - start_time
}
```
## Screenshots
### Before Caching
<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/uncached_fibonacci_20.png'>
<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/uncached_fibonacci_20_second.png'>
<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/uncached_fibonacci_25.png'>
### After Caching
<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/cached_factorial_250.png'>
<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/cached_factorial_250_second.png'>
<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/cached_fibonacci_300.png'>
<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/cached_fibonacci_20.png'>
## License
This library is released under the MIT License. See LICENSE for details.
## Contributing
Contributions are welcome! Please read our Contribution Guidelines for more details.
## Support
If you encounter any issues or have questions, please open an issue on GitHub.
## Acknowledgments
Thank you to the FastAPI community for inspiration and support.
Raw data
{
"_id": null,
"home_page": "",
"name": "CachiPy",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "cache,caching,API response,API caching,FastAPI cache,FastAPI caching,fastapi cacher",
"author": "Ambar Rizvi",
"author_email": "<brannstrom9911@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a8/11/a7f41227ce55589b39fecbb8a5b3cfa52bf84a02faaedf17d9654ddfbb1b/CachiPy-0.0.5.tar.gz",
"platform": null,
"description": "# CachiPy: A Caching Library for FastAPI\r\n\r\nCachiPy is a caching library specially designed for use with FastAPI. It allows you to easily cache API responses and improve the performance of your FastAPI applications.\r\n\r\n![CachiPy Logo](https://raw.githubusercontent.com/Ambar-06/CachiPy/main/CachiPy/CachiPy.png)\r\n\r\n## Features\r\n\r\n- Simple and efficient caching for FastAPI applications.\r\n- Support for caching API responses and function results.\r\n- Easy integration with FastAPI routes.\r\n- Customizable cache size and eviction policies.\r\n- Automatic cache clearing.\r\n\r\n## Installation\r\n\r\nYou can install CachiPy using pip:\r\n\r\n```bash\r\npip install CachiPy\r\n```\r\n## Usage\r\n```python\r\nfrom fastapi import FastAPI\r\nfrom CachiPy import cacheit\r\nimport time\r\n\r\napp = FastAPI()\r\n\r\n@cacheit\r\ndef factorial(n):\r\n if n <= 1:\r\n return 1\r\n else:\r\n return n * factorial(n - 1)\r\n\r\n# ... define FastAPI routes and route handlers ...\r\n\r\n# Use @cacheit decorator to cache results within your route handlers.\r\n```\r\nExample usage:\r\n```python\r\n@app.get(\"/factorial/{n}\")\r\ndef calculate_factorial(n: int):\r\n result = factorial(n)\r\n return {\r\n \"result\": result,\r\n \"execution_time\": end_time - start_time\r\n }\r\n```\r\n\r\n## Screenshots\r\n### Before Caching\r\n<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/uncached_fibonacci_20.png'>\r\n<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/uncached_fibonacci_20_second.png'>\r\n<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/uncached_fibonacci_25.png'>\r\n\r\n### After Caching\r\n<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/cached_factorial_250.png'>\r\n<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/cached_factorial_250_second.png'>\r\n<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/cached_fibonacci_300.png'>\r\n<img src='https://raw.githubusercontent.com/Ambar-06/CachiPy/main/screenshots/cached_fibonacci_20.png'>\r\n\r\n## License\r\nThis library is released under the MIT License. See LICENSE for details.\r\n\r\n## Contributing\r\nContributions are welcome! Please read our Contribution Guidelines for more details.\r\n\r\n## Support\r\nIf you encounter any issues or have questions, please open an issue on GitHub.\r\n\r\n## Acknowledgments\r\nThank you to the FastAPI community for inspiration and support.\r\n\r\n\r\n",
"bugtrack_url": null,
"license": "",
"summary": "A caching library specially designed for FastAPI",
"version": "0.0.5",
"project_urls": null,
"split_keywords": [
"cache",
"caching",
"api response",
"api caching",
"fastapi cache",
"fastapi caching",
"fastapi cacher"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8cdac7bc6202beaf7535afeb913f87a5c21622eb0e19cf762c190c1e5cf92348",
"md5": "5775d0c1f589191c338008bb5dc5ee1c",
"sha256": "c1d6c4c7e4b537fc97b949b5683651dfa3c7ad2a80de0b9d7027ecc0e09092f9"
},
"downloads": -1,
"filename": "CachiPy-0.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5775d0c1f589191c338008bb5dc5ee1c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 3299,
"upload_time": "2024-03-06T15:47:04",
"upload_time_iso_8601": "2024-03-06T15:47:04.774971Z",
"url": "https://files.pythonhosted.org/packages/8c/da/c7bc6202beaf7535afeb913f87a5c21622eb0e19cf762c190c1e5cf92348/CachiPy-0.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a811a7f41227ce55589b39fecbb8a5b3cfa52bf84a02faaedf17d9654ddfbb1b",
"md5": "5b7a3b982b37995c8d5d96d5ca5a8619",
"sha256": "3bb5992a8910ff54a44a06180eb8f5f3a282a5299b44cc322324268d41c20cb0"
},
"downloads": -1,
"filename": "CachiPy-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "5b7a3b982b37995c8d5d96d5ca5a8619",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3203,
"upload_time": "2024-03-06T15:47:07",
"upload_time_iso_8601": "2024-03-06T15:47:07.287068Z",
"url": "https://files.pythonhosted.org/packages/a8/11/a7f41227ce55589b39fecbb8a5b3cfa52bf84a02faaedf17d9654ddfbb1b/CachiPy-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-06 15:47:07",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cachipy"
}