Giter Site home page Giter Site logo

iamsinghrajat / async-cache Goto Github PK

View Code? Open in Web Editor NEW
91.0 1.0 20.0 59 KB

A caching solution for asyncio

Home Page: https://pypi.org/project/async-cache/

License: MIT License

Python 100.00%
asyncio lru-cache lru async async-cache ttl ttl-cache ttl-cache-implementation coroutines asynchronous

async-cache's People

Contributors

asymptotal avatar caidenlemiha avatar dcrowe avatar iamsinghrajat avatar mt-rajat-singh avatar y-u-n-ii-a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

async-cache's Issues

cache.key.KEY error

Rarely, but sometimes the unknown error happens, when a function with @AsyncTTL decorator is called:<cache.key.KEY object at 0x7f242580c460>
``text
File "/usr/local/lib/python3.10/site-packages/cache/async_ttl.py", line 56, in wrapper
self.ttl[key] = await func(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/cache/async_ttl.py", line 36, in setitem
super().setitem(key, (value, ttl_value))
File "/usr/local/lib/python3.10/site-packages/cache/lru.py", line 17, in setitem
oldest = next(iter(self))

Add option to ignore some parameters when making key

There are some occasions when it's useful to ignore some parameters for the purpose of determining a key. For example if you're caching a method, it might be that self is irrelevant to the desired caching behaviour.

New release

Hello,

could you please create a release with latest changes on PyPI? For example the use_cache function is not yet available in the released version.

Thanks in advance.

Parameter time_to_live do it for hours, days, etc..

datetime.datetime.now() + self.time_to_live

self.time_to_live = datetime.timedelta(

It is better to pass the exact parameter for

@AsyncTTL(hours=1, seconds=1, days=0, milliseconds=0, ... etc. , maxsize=1024)

datetime.timedelta(
    days=days,
    seconds=seconds,
    microseconds=microseconds,
    milliseconds=milliseconds,
    minutes=minutes,
    hours=hours,
    weeks=weeks
)

`SyntaxError: invalid syntax` in import statement

I get this error when i try to run the code with import like from async-cache import AsyncLRU.

  File "app/workers/simulator.py", line 7
    from async-cache import AsyncLRU
         ^
SyntaxError: invalid syntax

Look like the - in the name is the problem.
In vsc I see the two world asyncand cache in different colors as lint flag it as error.
image

Is this a bug or am I doing something wrong?

Feature Request: cache_info() like cachetools

cachetools' cached decoractor has an info param that adds a wrapped info function for getting details on cache usage, which can be helpful for debugging. From their docs:

If info is set to True, the wrapped function is instrumented with a cache_info() function that returns a named tuple showing hits, misses, maxsize and currsize, to help measure the effectiveness of the cache.

Would be nice to have something similar here!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.