cache: Delete user_profile_by_email_cache_key.

This is no longer used in any important place,
get_user_profile_by_email is meant to be used only in manage.py shell
now and thus there's no point in this function being cached.
This commit is contained in:
Mateusz Mandera 2021-03-17 15:37:43 +01:00 committed by Tim Abbott
parent a094b80fb1
commit 82d6d925e5
2 changed files with 1 additions and 11 deletions

View File

@ -487,13 +487,6 @@ def display_recipient_bulk_get_users_by_id_cache_key(user_id: int) -> str:
return "bulk_fetch_display_recipients:" + user_profile_by_id_cache_key(user_id)
def user_profile_by_email_cache_key(email: str) -> str:
# See the comment in zerver/lib/avatar_hash.py:gravatar_hash for why we
# are proactively encoding email addresses even though they will
# with high likelihood be ASCII-only for the foreseeable future.
return f"user_profile_by_email:{make_safe_digest(email.strip())}"
def user_profile_cache_key_id(email: str, realm_id: int) -> str:
return f"user_profile:{make_safe_digest(email.strip())}:{realm_id}"
@ -585,7 +578,6 @@ def delete_user_profile_caches(user_profiles: Iterable["UserProfile"]) -> None:
keys = []
for user_profile in user_profiles:
keys.append(user_profile_by_email_cache_key(user_profile.delivery_email))
keys.append(user_profile_by_id_cache_key(user_profile.id))
for api_key in get_all_api_keys(user_profile):
keys.append(user_profile_by_api_key_cache_key(api_key))

View File

@ -62,7 +62,6 @@ from zerver.lib.cache import (
realm_user_dict_fields,
realm_user_dicts_cache_key,
user_profile_by_api_key_cache_key,
user_profile_by_email_cache_key,
user_profile_by_id_cache_key,
user_profile_cache_key,
)
@ -2617,9 +2616,8 @@ def get_user_profile_by_id(uid: int) -> UserProfile:
return UserProfile.objects.select_related().get(id=uid)
@cache_with_key(user_profile_by_email_cache_key, timeout=3600 * 24 * 7)
def get_user_profile_by_email(email: str) -> UserProfile:
"""This function is intended to be used by our unit tests and for
"""This function is intended to be used for
manual manage.py shell work; robust code must use get_user or
get_user_by_delivery_email instead, because Zulip supports
multiple users with a given (delivery) email address existing on a