Coverage for src / lexigram / contracts / admin / cache_provider.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-08-15 18:58 +0800

1"""CacheProviderProtocol — admin-side cache facade.""" 

2 

3from __future__ import annotations 

4 

5from typing import Any, Protocol, runtime_checkable 

6 

7 

8@runtime_checkable 

9class CacheProviderProtocol(Protocol): 

10 """Protocol for admin data-layer cache providers. 

11 

12 Provides basic get/set/delete/invalidate operations with TTL and tag 

13 support. Tags are used for grouped invalidation. 

14 

15 This is the admin-internal cache abstraction, distinct from 

16 ``lexigram.contracts.cache.CacheBackend`` which is the framework-wide 

17 Redis/memory cache contract. 

18 """ 

19 

20 async def get(self, key: str) -> Any | None: ... 

21 

22 async def set( 

23 self, 

24 key: str, 

25 value: Any, 

26 ttl: int = 300, 

27 tags: list[str] | None = None, 

28 ) -> None: ... 

29 

30 async def delete(self, key: str) -> None: ... 

31 

32 async def invalidate_tags(self, tags: list[str]) -> None: ... 

33 

34 

35__all__ = ["CacheProviderProtocol"]