Remove as_compressed_state cache (#93169)

* Remove as_compressed_state cache

All calls to as_compressed_state are now covered by a higher level
JSON cache so there is no need to store these in memory anymore

* Remove as_compressed_state cache

All calls to as_compressed_state are now covered by a higher level
JSON cache so there is no need to store these in memory anymore
This commit is contained in:
J. Nick Koston 2023-05-16 12:39:16 -05:00 committed by GitHub
parent e949344dd9
commit bf16f6b104
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 7 deletions

View File

@ -1224,7 +1224,6 @@ class State:
"domain",
"object_id",
"_as_dict",
"_as_compressed_state",
"_as_dict_json",
"_as_compressed_state_json",
)
@ -1262,7 +1261,6 @@ class State:
self.context = context or Context()
self.domain, self.object_id = split_entity_id(self.entity_id)
self._as_dict: ReadOnlyDict[str, Collection[Any]] | None = None
self._as_compressed_state: dict[str, Any] | None = None
self._as_dict_json: str | None = None
self._as_compressed_state_json: str | None = None
@ -1312,8 +1310,6 @@ class State:
Sends c (context) as a string if it only contains an id.
"""
if self._as_compressed_state:
return self._as_compressed_state
state_context = self.context
if state_context.parent_id is None and state_context.user_id is None:
context: dict[str, Any] | str = state_context.id
@ -1329,7 +1325,6 @@ class State:
compressed_state[COMPRESSED_STATE_LAST_UPDATED] = dt_util.utc_to_timestamp(
self.last_updated
)
self._as_compressed_state = compressed_state
return compressed_state
def as_compressed_state_json(self) -> str:

View File

@ -511,7 +511,6 @@ def test_state_as_compressed_state() -> None:
assert as_compressed_state == expected
# 2nd time to verify cache
assert state.as_compressed_state() == expected
assert state.as_compressed_state() is as_compressed_state
def test_state_as_compressed_state_unique_last_updated() -> None:
@ -538,7 +537,6 @@ def test_state_as_compressed_state_unique_last_updated() -> None:
assert as_compressed_state == expected
# 2nd time to verify cache
assert state.as_compressed_state() == expected
assert state.as_compressed_state() is as_compressed_state
def test_state_as_compressed_state_json() -> None: