async-cache
===========
:info: A caching solution for asyncio
.. image:: https://travis-ci.org/iamsinghrajat/async-cache.svg?branch=master
:target: https://travis-ci.org/iamsinghrajat/async-cache
.. image:: https://img.shields.io/pypi/v/async-cache.svg
:target: https://pypi.python.org/pypi/async-cache
.. image:: https://www.codetriage.com/iamsinghrajat/async-cache/badges/users.svg
:target: https://pypi.python.org/pypi/async-cache
Installation
------------
.. code-block:: shell
pip install async-cache
Basic Usage
-----------
.. code-block:: python
# LRU Cache
from cache import AsyncLRU
@AsyncLRU(maxsize=128)
async def func(*args, **kwargs):
"""
maxsize : max number of results that are cached.
if max limit is reached the oldest result is deleted.
"""
pass
# TTL Cache
from cache import AsyncTTL
@AsyncTTL(time_to_live=60, maxsize=1024)
async def func(*args, **kwargs):
"""
time_to_live : max time for which a cached result is valid
maxsize : max number of results that are cached.
if max limit is reached the oldest result is deleted.
"""
pass
# Supports primitive as well as non-primitive function parameter.
# Currently TTL & LRU cache is supported.
Advanced Usage
--------------
.. code-block:: python
class CustomDataClass:
id: int
value: int
from cache import AsyncLRU
@AsyncLRU(maxsize=128)
async def func(model: "CustomDataClass"):
...
# function logic
...
# async-cache will work even if function parameters are:
# 1. orm objects
# 2. request object
# 3. any other custom object type.
Raw data
{
"_id": null,
"home_page": "https://github.com/iamsinghrajat/async-cache",
"name": "async-cache",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.3",
"maintainer_email": "",
"keywords": "asyncio,lru,cache,async,cache,lru-cache,ttl",
"author": "Rajat Singh",
"author_email": "iamsinghrajat@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/73/6e/908402652bf7d8ab02fa204399d9517d247fb3a0926045a8c8a28708cd40/async-cache-1.1.1.tar.gz",
"platform": "",
"description": "async-cache\n===========\n:info: A caching solution for asyncio\n\n.. image:: https://travis-ci.org/iamsinghrajat/async-cache.svg?branch=master\n :target: https://travis-ci.org/iamsinghrajat/async-cache\n.. image:: https://img.shields.io/pypi/v/async-cache.svg\n :target: https://pypi.python.org/pypi/async-cache\n.. image:: https://www.codetriage.com/iamsinghrajat/async-cache/badges/users.svg\n :target: https://pypi.python.org/pypi/async-cache\n\n\nInstallation\n------------\n\n.. code-block:: shell\n\n pip install async-cache\n\nBasic Usage\n-----------\n\n.. code-block:: python\n \n # LRU Cache\n from cache import AsyncLRU\n \n @AsyncLRU(maxsize=128)\n async def func(*args, **kwargs):\n \"\"\"\n maxsize : max number of results that are cached.\n if max limit is reached the oldest result is deleted.\n \"\"\"\n pass\n \n \n # TTL Cache\n from cache import AsyncTTL\n \n @AsyncTTL(time_to_live=60, maxsize=1024)\n async def func(*args, **kwargs):\n \"\"\"\n time_to_live : max time for which a cached result is valid\n maxsize : max number of results that are cached.\n if max limit is reached the oldest result is deleted.\n \"\"\"\n pass\n\n # Supports primitive as well as non-primitive function parameter.\n # Currently TTL & LRU cache is supported.\n\nAdvanced Usage\n--------------\n\n.. code-block:: python\n \n class CustomDataClass:\n id: int\n value: int\n \n \n from cache import AsyncLRU\n \n @AsyncLRU(maxsize=128)\n async def func(model: \"CustomDataClass\"):\n ...\n # function logic\n ...\n \n # async-cache will work even if function parameters are:\n # 1. orm objects\n # 2. request object\n # 3. any other custom object type.",
"bugtrack_url": null,
"license": "",
"summary": "An asyncio Cache",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/iamsinghrajat/async-cache"
},
"split_keywords": [
"asyncio",
"lru",
"cache",
"async",
"cache",
"lru-cache",
"ttl"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "736e908402652bf7d8ab02fa204399d9517d247fb3a0926045a8c8a28708cd40",
"md5": "1ec882a46cb9524a3bfe3837caf7a29d",
"sha256": "81aa9ccd19fb06784aaf30bd5f2043dc0a23fc3e998b93d0c2c17d1af9803393"
},
"downloads": -1,
"filename": "async-cache-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "1ec882a46cb9524a3bfe3837caf7a29d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.3",
"size": 3848,
"upload_time": "2021-07-03T18:24:36",
"upload_time_iso_8601": "2021-07-03T18:24:36.769697Z",
"url": "https://files.pythonhosted.org/packages/73/6e/908402652bf7d8ab02fa204399d9517d247fb3a0926045a8c8a28708cd40/async-cache-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-07-03 18:24:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "iamsinghrajat",
"github_project": "async-cache",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "async-cache"
}