Skip to content

Commit

Permalink
use built-in cache instead of cached_property
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
  • Loading branch information
andrewwhitehead committed Jan 22, 2025
1 parent ece9c42 commit ecbc7a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
31 changes: 20 additions & 11 deletions wrappers/python/aries_askar/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
except ImportError:
import json

from functools import lru_cache
from typing import Optional, Sequence, Union

from cached_property import cached_property

from . import bindings
from .bindings import (
EntryListHandle,
Expand All @@ -32,22 +31,26 @@ def __init__(self, lst: EntryListHandle, pos: int):
self._list = lst
self._pos = pos

@cached_property
@property
@lru_cache(maxsize=None)
def category(self) -> str:
"""Accessor for the entry category."""
return self._list.get_category(self._pos)

@cached_property
@property
@lru_cache(maxsize=None)
def name(self) -> str:
"""Accessor for the entry name."""
return self._list.get_name(self._pos)

@property
@lru_cache(maxsize=None)
def value(self) -> bytes:
"""Accessor for the entry value."""
return bytes(self.raw_value)

@cached_property
@property
@lru_cache(maxsize=None)
def raw_value(self) -> memoryview:
"""Accessor for the entry raw value."""
return self._list.get_value(self._pos)
Expand All @@ -57,7 +60,8 @@ def value_json(self) -> dict:
"""Accessor for the entry value as JSON."""
return json.loads(self.value)

@cached_property
@property
@lru_cache(maxsize=None)
def tags(self) -> dict:
"""Accessor for the entry tags."""
return self._list.get_tags(self._pos)
Expand Down Expand Up @@ -147,27 +151,32 @@ def __init__(self, lst: KeyEntryListHandle, pos: int):
self._list = lst
self._pos = pos

@cached_property
@property
@lru_cache(maxsize=None)
def algorithm(self) -> str:
"""Accessor for the key entry algorithm."""
return self._list.get_algorithm(self._pos)

@cached_property
@property
@lru_cache(maxsize=None)
def name(self) -> str:
"""Accessor for the key entry name."""
return self._list.get_name(self._pos)

@cached_property
@property
@lru_cache(maxsize=None)
def metadata(self) -> str:
"""Accessor for the key entry metadata."""
return self._list.get_metadata(self._pos)

@cached_property
@property
@lru_cache(maxsize=None)
def key(self) -> Key:
"""Accessor for the entry metadata."""
return Key(self._list.load_key(self._pos))

@cached_property
@property
@lru_cache(maxsize=None)
def tags(self) -> dict:
"""Accessor for the entry tags."""
return self._list.get_tags(self._pos)
Expand Down
1 change: 0 additions & 1 deletion wrappers/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
cached_property~=2.0.0

0 comments on commit ecbc7a8

Please sign in to comment.