mirror of https://github.com/zulip/zulip.git
cache: Eliminate transformed_bulk_cached_fetch.
Its two callers now just directly call generic_bulk_cached_fetch with the explicit `lambda obj: obj` helpers.
This commit is contained in:
parent
d19c1f7438
commit
3599b1662e
|
@ -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(
|
def bulk_cached_fetch(
|
||||||
cache_key_function: Callable[[ObjKT], str],
|
cache_key_function: Callable[[ObjKT], str],
|
||||||
query_function: Callable[[List[ObjKT]], Iterable[ItemT]],
|
query_function: Callable[[List[ObjKT]], Iterable[ItemT]],
|
||||||
|
@ -421,11 +402,13 @@ def bulk_cached_fetch(
|
||||||
*,
|
*,
|
||||||
id_fetcher: Callable[[ItemT], ObjKT],
|
id_fetcher: Callable[[ItemT], ObjKT],
|
||||||
) -> Dict[ObjKT, ItemT]:
|
) -> Dict[ObjKT, ItemT]:
|
||||||
return transformed_bulk_cached_fetch(
|
return generic_bulk_cached_fetch(
|
||||||
cache_key_function,
|
cache_key_function,
|
||||||
query_function,
|
query_function,
|
||||||
object_ids,
|
object_ids,
|
||||||
id_fetcher=id_fetcher,
|
id_fetcher=id_fetcher,
|
||||||
|
extractor=lambda obj: obj,
|
||||||
|
setter=lambda obj: obj,
|
||||||
cache_transformer=lambda obj: obj,
|
cache_transformer=lambda obj: obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ from zerver.lib.cache import (
|
||||||
bulk_cached_fetch,
|
bulk_cached_fetch,
|
||||||
cache_with_key,
|
cache_with_key,
|
||||||
display_recipient_cache_key,
|
display_recipient_cache_key,
|
||||||
|
generic_bulk_cached_fetch,
|
||||||
single_user_display_recipient_cache_key,
|
single_user_display_recipient_cache_key,
|
||||||
transformed_bulk_cached_fetch,
|
|
||||||
)
|
)
|
||||||
from zerver.lib.types import DisplayRecipientT, UserDisplayRecipient
|
from zerver.lib.types import DisplayRecipientT, UserDisplayRecipient
|
||||||
from zerver.models import Recipient, Stream, UserProfile, bulk_get_huddle_user_ids
|
from zerver.models import Recipient, Stream, UserProfile, bulk_get_huddle_user_ids
|
||||||
|
@ -103,12 +103,14 @@ def bulk_fetch_stream_names(
|
||||||
return row["name"]
|
return row["name"]
|
||||||
|
|
||||||
# ItemT = TinyStreamResult, CacheItemT = str (name), ObjKT = int (recipient_id)
|
# 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,
|
cache_key_function=display_recipient_cache_key,
|
||||||
query_function=get_tiny_stream_rows,
|
query_function=get_tiny_stream_rows,
|
||||||
object_ids=recipient_ids,
|
object_ids=recipient_ids,
|
||||||
id_fetcher=get_recipient_id,
|
id_fetcher=get_recipient_id,
|
||||||
cache_transformer=get_name,
|
cache_transformer=get_name,
|
||||||
|
setter=lambda obj: obj,
|
||||||
|
extractor=lambda obj: obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
return stream_display_recipients
|
return stream_display_recipients
|
||||||
|
|
Loading…
Reference in New Issue