Skip to content

LeonMar97/cache-decorator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cache-decorator

python decorator with caching capabilities.

How to use

Basically import the decorator function from module and add it to any function which returns something to cache. the use_cache is set to use by default, and checks whether the function ran before and returns the cache value if it did. if value "False" is passed to function call the fuction will be called, the value is being cached anyway.

Add a decorator example

from cache_decorator_m import cache_decorator
@cache_decorator
def greet(name):
    return "hello {}".format(name)

Call the decorator without cache

print(greet("michal",use_cache=False))

Output

not in cache
hello michal

Call the decorator with cache right after

print(greet("michal",use_cache=False))
print(greet("michal",use_cache=True))

Output

not in cache
hello michal
this what ive found in cache :
hello michal

List of files:

cache_decorator_m.py : cache decorator module.
check_decorator.py : just an example use of file.

About

cache-decorator made in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages