diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py index 5e38cadb8d..07003e749d 100644 --- a/zerver/lib/cache.py +++ b/zerver/lib/cache.py @@ -395,25 +395,6 @@ def generic_bulk_cached_fetch( } -def transformed_bulk_cached_fetch( - cache_key_function: Callable[[ObjKT], str], - query_function: Callable[[List[ObjKT]], Iterable[ItemT]], - object_ids: Sequence[ObjKT], - *, - id_fetcher: Callable[[ItemT], ObjKT], - cache_transformer: Callable[[ItemT], CacheItemT], -) -> Dict[ObjKT, CacheItemT]: - return generic_bulk_cached_fetch( - cache_key_function, - query_function, - object_ids, - extractor=lambda obj: obj, - setter=lambda obj: obj, - id_fetcher=id_fetcher, - cache_transformer=cache_transformer, - ) - - def bulk_cached_fetch( cache_key_function: Callable[[ObjKT], str], query_function: Callable[[List[ObjKT]], Iterable[ItemT]], @@ -421,11 +402,13 @@ def bulk_cached_fetch( *, id_fetcher: Callable[[ItemT], ObjKT], ) -> Dict[ObjKT, ItemT]: - return transformed_bulk_cached_fetch( + return generic_bulk_cached_fetch( cache_key_function, query_function, object_ids, id_fetcher=id_fetcher, + extractor=lambda obj: obj, + setter=lambda obj: obj, cache_transformer=lambda obj: obj, ) diff --git a/zerver/lib/display_recipient.py b/zerver/lib/display_recipient.py index 4344e40a99..bfec6c2825 100644 --- a/zerver/lib/display_recipient.py +++ b/zerver/lib/display_recipient.py @@ -6,8 +6,8 @@ from zerver.lib.cache import ( bulk_cached_fetch, cache_with_key, display_recipient_cache_key, + generic_bulk_cached_fetch, single_user_display_recipient_cache_key, - transformed_bulk_cached_fetch, ) from zerver.lib.types import DisplayRecipientT, UserDisplayRecipient from zerver.models import Recipient, Stream, UserProfile, bulk_get_huddle_user_ids @@ -103,12 +103,14 @@ def bulk_fetch_stream_names( return row["name"] # ItemT = TinyStreamResult, CacheItemT = str (name), ObjKT = int (recipient_id) - stream_display_recipients: Dict[int, str] = transformed_bulk_cached_fetch( + stream_display_recipients: Dict[int, str] = generic_bulk_cached_fetch( cache_key_function=display_recipient_cache_key, query_function=get_tiny_stream_rows, object_ids=recipient_ids, id_fetcher=get_recipient_id, cache_transformer=get_name, + setter=lambda obj: obj, + extractor=lambda obj: obj, ) return stream_display_recipients