Skip to content

Commit ae1cc7e

Browse files
author
Fabien Coelho
committed
improve selling point
1 parent beef799 commit ae1cc7e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

README.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# CacheToolsUtils
22

3-
Stackable cache classes, for instance to add key prefix and stats to
4-
[cachetools](https://pypi.org/project/cachetools/) classes and use
5-
[redis](https://redis.io/) and
6-
[memcached](https://memcached.org/) as storage backends,
7-
and other cache-related utils.
3+
Stackable cache classes for sharing, encryption, statistics _and more_
4+
on top of [cachetools](https://pypi.org/project/cachetools/),
5+
[redis](https://redis.io/) and [memcached](https://memcached.org/).
86

97
![Status](https://github.com/zx80/cachetools-utils/actions/workflows/ctu.yml/badge.svg?branch=main&style=flat)
108
![Tests](https://img.shields.io/badge/tests-23%20✓-success)
@@ -40,9 +38,14 @@ def repeat(s: str, n: int) -> str:
4038
def banged(s: str, n: int) -> str:
4139
return repeat(s, n) + "!"
4240

43-
print(banged("aa", 3)) # add 2 cache entries
44-
print(repeat("aa", 3)) # cache hit!
45-
print(banged("aa", 3)) # cache hit!
41+
@ctu.cached(ctu.AutoPrefixedCache(cache), key=ctu.json_key)
42+
def question(s: str, n: int) -> str:
43+
return repeat(s, n) + "?"
44+
45+
print(banged("aa", 3)) # add 2 cache entries
46+
print(question("aa", 3)) # add 1 entry, 1 hit
47+
print(repeat("aa", 3)) # cache hit!
48+
print(banged("aa", 3)) # cache hit!
4649

4750
assert cache.hits() > 0
4851
```

0 commit comments

Comments
 (0)