mirror of
https://github.com/datafolklabs/cement.git
synced 2026-02-06 11:56:51 +00:00
Type Annotations: core.cache
- Resolves Issue #693 - Related to PR #628
This commit is contained in:
parent
b5f579a499
commit
01bcc70e0c
@ -24,6 +24,7 @@ Refactoring:
|
||||
- `[dev]` Added Python 3.13 Dev Target
|
||||
- Type Annotations (related: [PR #628](https://github.com/datafolklabs/cement/pull/628))
|
||||
- `[core.arg]` [Issue #692](https://github.com/datafolklabs/cement/issues/692)
|
||||
- `[core.cache]` [Issue #692](https://github.com/datafolklabs/cement/issues/693)
|
||||
- `[core.exc]` [Issue #697](https://github.com/datafolklabs/cement/issues/697)
|
||||
- `[core.interface]` [Issue #702](https://github.com/datafolklabs/cement/issues/702)
|
||||
- `[core.meta]` [Issue #705](https://github.com/datafolklabs/cement/issues/705)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
"""Cement core cache module."""
|
||||
|
||||
from abc import abstractmethod
|
||||
from typing import Any, Optional
|
||||
from ..core.interface import Interface
|
||||
from ..core.handler import Handler
|
||||
from ..utils.misc import minimal_logger
|
||||
@ -25,7 +26,7 @@ class CacheInterface(Interface):
|
||||
interface = 'cache'
|
||||
|
||||
@abstractmethod
|
||||
def get(self, key, fallback=None):
|
||||
def get(self, key: str, fallback: Any = None) -> Any:
|
||||
"""
|
||||
Get the value for a key in the cache.
|
||||
|
||||
@ -47,7 +48,7 @@ class CacheInterface(Interface):
|
||||
pass # pragma: nocover
|
||||
|
||||
@abstractmethod
|
||||
def set(self, key, value, time=None):
|
||||
def set(self, key: str, value: Any, time: Optional[int] = None) -> None:
|
||||
"""
|
||||
Set the key/value in the cache for a set amount of ``time``.
|
||||
|
||||
@ -66,7 +67,7 @@ class CacheInterface(Interface):
|
||||
pass # pragma: nocover
|
||||
|
||||
@abstractmethod
|
||||
def delete(self, key):
|
||||
def delete(self, key: str) -> bool:
|
||||
"""
|
||||
Deletes a key/value from the cache.
|
||||
|
||||
@ -81,7 +82,7 @@ class CacheInterface(Interface):
|
||||
pass # pragma: nocover
|
||||
|
||||
@abstractmethod
|
||||
def purge(self):
|
||||
def purge(self) -> None:
|
||||
"""
|
||||
Clears all data from the cache.
|
||||
|
||||
@ -95,4 +96,5 @@ class CacheHandler(CacheInterface, Handler):
|
||||
Cache handler implementation.
|
||||
|
||||
"""
|
||||
pass # pragma: nocover
|
||||
class Meta:
|
||||
pass # pragma: nocover
|
||||
|
||||
Loading…
Reference in New Issue
Block a user