Skip to content

Commit e53eb1f

Browse files
committed
feat(docs): update theme options and improve documentation
- Add issue button and adjust TOC level in docs theme options - Simplify description in index.rst - Add version 0.5 release notes with new features - Update cache.py with new methods and versionadded markers - Create exceptions.py with new exception classes
1 parent 3b6c3f1 commit e53eb1f

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

docs/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
"use_download_button": True,
6363
"use_fullscreen_button": True,
6464
"use_repository_button": True,
65+
"use_issues_button": True,
66+
"use_download_button": True,
67+
"show_toc_level": 2,
6568
}
6669

6770
# -- Options for autodoc ----------------------------------------------------

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ redis_func_cache
2323
:target: https://pypi.org/project/redis_func_cache/
2424

2525
.. rubric::
26-
``redis_func_cache`` is a Python library for caching function results in `Redis <https://redis.io/>`_, similar to the caching functionality provided by the standard library's `functools <https://docs.python.org/library/functools.html>`_ module.
26+
A Python library for caching function results in Redis, similar to the caching functionality provided by the standard library's functools.cache.
2727

2828
========== ========= =========
2929
Release Version Built at

src/redis_func_cache/cache.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class Mode:
101101
"""A :func:`dataclasses.dataclass` for cache operation mode flags.
102102
103103
Defines how the cache behaves when executing decorated functions.
104+
105+
.. versionadded:: 0.5
104106
"""
105107

106108
read: bool = True
@@ -167,6 +169,8 @@ def __init__(
167169
168170
Assigned to property :attr:`update_ttl`.
169171
172+
.. versionadded:: 0.5
173+
170174
prefix: The prefix for cache keys.
171175
172176
If not provided, the default is :data:`.DEFAULT_PREFIX`.
@@ -366,6 +370,8 @@ def get_client(self) -> RedisClientTV:
366370
367371
Caution:
368372
When using the factory pattern (a :term:`callable` object is passed to the ``client`` :term:`argument` of the constructor), **the factory function will be invoked every time this method is called**, and its return value will be used as the method's return value.
373+
374+
.. versionadded:: 0.5
369375
"""
370376
if self._redis_instance:
371377
return self._redis_instance
@@ -846,13 +852,21 @@ def get_mode(self) -> RedisFuncCache.Mode:
846852
"""Return a **copy** of the cache mode.
847853
848854
The cache mode inside the class instance is contextual variable, which is thread local and thread safe.
855+
856+
.. versionadded:: 0.5
849857
"""
850858
return copy(self._mode.get())
851859

852860
def set_mode(self, mode: RedisFuncCache.Mode) -> Token[RedisFuncCache.Mode]:
861+
"""
862+
.. versionadded:: 0.5
863+
"""
853864
return self._mode.set(mode)
854865

855866
def reset_mode(self, token: Token[RedisFuncCache.Mode]):
867+
"""
868+
.. versionadded:: 0.5
869+
"""
856870
self._mode.reset(token)
857871

858872
@contextmanager
@@ -881,6 +895,8 @@ def func(): ...
881895
882896
with cache.scoped_mode(mode):
883897
result = func() # will be executed without cache write
898+
899+
.. versionadded:: 0.5
884900
"""
885901
token = self._mode.set(mode)
886902
try:
@@ -902,8 +918,10 @@ def disable_rw(self) -> Generator[None, None, None]:
902918
def func(): ...
903919
904920
905-
with cache.disabled():
921+
with cache.disable_rw():
906922
result = func() # will be executed without cache ability
923+
924+
.. versionadded:: 0.5
907925
"""
908926
mode = replace(self._mode.get(), read=False, write=False)
909927
with self.scoped_mode(mode):
@@ -927,6 +945,8 @@ def func(): ...
927945
928946
with cache.read_only():
929947
result = func()
948+
949+
.. versionadded:: 0.5
930950
"""
931951
mode = replace(self._mode.get(), read=True, write=False)
932952
with self.scoped_mode(mode):
@@ -946,6 +966,8 @@ def func(): ...
946966
947967
with cache.disable_read():
948968
result = func() # will be executed and result stored in cache, but not read from cache
969+
970+
.. versionadded:: 0.5
949971
"""
950972
mode = replace(self._mode.get(), read=False, write=True)
951973
with self.scoped_mode(mode):

src/redis_func_cache/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
.. versionadded:: 0.5
3+
"""
4+
15
__all__ = ("BaseCacheError", "CacheMissError")
26

37

0 commit comments

Comments
 (0)