diff --git a/README.rst b/README.rst index 329c412..5b11033 100644 --- a/README.rst +++ b/README.rst @@ -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(): diff --git a/examples/configuration/custom_configuration.py b/examples/configuration/custom_configuration.py index 59bca48..29d1cab 100644 --- a/examples/configuration/custom_configuration.py +++ b/examples/configuration/custom_configuration.py @@ -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(): diff --git a/memoize/statuses.py b/memoize/statuses.py index 1f2dfd4..664d7ea 100644 --- a/memoize/statuses.py +++ b/memoize/statuses.py @@ -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)."""