Skip to content

Commit

Permalink
Improve diff
Browse files Browse the repository at this point in the history
  • Loading branch information
zmumi committed Sep 30, 2024
1 parent 8aa8573 commit 541a5ff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ Example how to customize default config (everything gets overridden):
@memoize(
configuration=MutableCacheConfiguration
.initialized_with(DefaultInMemoryCacheConfiguration())
.set_method_timeout(value=timedelta(minutes=2))
.set_entry_builder(ProvidedLifeSpanCacheEntryBuilder(update_after=timedelta(minutes=2),
expire_after=timedelta(minutes=5)))
.set_eviction_strategy(LeastRecentlyUpdatedEvictionStrategy(capacity=2048))
.set_key_extractor(EncodedMethodNameAndArgsKeyExtractor(skip_first_arg_as_self=False))
.set_storage(LocalInMemoryCacheStorage())
.set_postprocessing(DeepcopyPostprocessing()),
.initialized_with(DefaultInMemoryCacheConfiguration())
.set_method_timeout(value=timedelta(minutes=2))
.set_entry_builder(ProvidedLifeSpanCacheEntryBuilder(update_after=timedelta(minutes=2),
expire_after=timedelta(minutes=5)))
.set_eviction_strategy(LeastRecentlyUpdatedEvictionStrategy(capacity=2048))
.set_key_extractor(EncodedMethodNameAndArgsKeyExtractor(skip_first_arg_as_self=False))
.set_storage(LocalInMemoryCacheStorage())
.set_postprocessing(DeepcopyPostprocessing()),
update_statuses=InMemoryLocks(update_lock_timeout=timedelta(minutes=5))
)
async def cached():
Expand Down
16 changes: 8 additions & 8 deletions examples/configuration/custom_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

@memoize(
configuration=MutableCacheConfiguration
.initialized_with(DefaultInMemoryCacheConfiguration())
.set_method_timeout(value=timedelta(minutes=2))
.set_entry_builder(ProvidedLifeSpanCacheEntryBuilder(update_after=timedelta(minutes=2),
expire_after=timedelta(minutes=5)))
.set_eviction_strategy(LeastRecentlyUpdatedEvictionStrategy(capacity=2048))
.set_key_extractor(EncodedMethodNameAndArgsKeyExtractor(skip_first_arg_as_self=False))
.set_storage(LocalInMemoryCacheStorage())
.set_postprocessing(DeepcopyPostprocessing()),
.initialized_with(DefaultInMemoryCacheConfiguration())
.set_method_timeout(value=timedelta(minutes=2))
.set_entry_builder(ProvidedLifeSpanCacheEntryBuilder(update_after=timedelta(minutes=2),
expire_after=timedelta(minutes=5)))
.set_eviction_strategy(LeastRecentlyUpdatedEvictionStrategy(capacity=2048))
.set_key_extractor(EncodedMethodNameAndArgsKeyExtractor(skip_first_arg_as_self=False))
.set_storage(LocalInMemoryCacheStorage())
.set_postprocessing(DeepcopyPostprocessing()),
update_statuses=InMemoryLocks(update_lock_timeout=timedelta(minutes=5))
)
async def cached():
Expand Down
10 changes: 5 additions & 5 deletions memoize/statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@
class UpdateStatuses(metaclass=ABCMeta):
@abstractmethod
def is_being_updated(self, key: CacheKey) -> bool:
"""Check if update for given key is in progress. Obtained info is valid until control gets back to IO-loop."""
"""Checks if update for given key is in progress. Obtained info is valid until control gets back to IO-loop."""
raise NotImplementedError()

@abstractmethod
def mark_being_updated(self, key: CacheKey) -> None:
"""Inform that update has been started.
"""Informs that update has been started.
Should be called only if 'is_being_updated' returned False (and since then IO-loop has not been lost)..
Calls to 'is_being_updated' will return True until 'mark_updated' will be called."""
raise NotImplementedError()

def mark_updated(self, key: CacheKey, entry: CacheEntry) -> None:
"""Inform that update has been finished.
"""Informs that update has been finished.
Calls to 'is_being_updated' will return False until 'mark_being_updated' will be called."""
raise NotImplementedError()

@abstractmethod
def mark_update_aborted(self, key: CacheKey, exception: Exception) -> None:
"""Inform that update failed to complete.
"""Informs that update failed to complete.
Calls to 'is_being_updated' will return False until 'mark_being_updated' will be called.
Accepts exception to propagate it across all clients awaiting an update."""
raise NotImplementedError()

@abstractmethod
def await_updated(self, key: CacheKey) -> Awaitable[Union[CacheEntry, Exception]]:
"""Wait (asynchronously) until update in progress has benn finished.
"""Waits (asynchronously) until update in progress has benn finished.
Returns awaitable with the updated entry
(or awaitable with an exception if update failed/timed-out).
Should be called only if 'is_being_updated' returned True (and since then IO-loop has not been lost)."""
Expand Down

0 comments on commit 541a5ff

Please sign in to comment.