Skip to content

Commit

Permalink
Additional warnings around unexpected cache behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ankohanse committed Dec 9, 2024
1 parent acd1119 commit 741fb20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions custom_components/studer_xcom/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,19 +441,25 @@ async def _async_read_cache(self):
store = await self._store.async_get_data() or {}
self._cache = store.get("cache", {})
else:
_LOGGER.warning(f"Using empty cache; no store available to read persisted cache from")
_LOGGER.warning(f"Using empty cache; no store available to read from")
self._cache = {}


async def _async_persist_cache(self):
if self._store and (datetime.now() - self._cache_last_write).total_seconds() > CACHE_WRITE_PERIOD:
if self._is_temp:
return

if self._store:
if (datetime.now() - self._cache_last_write).total_seconds() > CACHE_WRITE_PERIOD:

_LOGGER.debug(f"Persist cache")
self._cache_last_write = datetime.now()
_LOGGER.debug(f"Persist cache")
self._cache_last_write = datetime.now()

store = await self._store.async_get_data() or {}
store["cache"] = self._cache
await self._store.async_set_data(store)
store = await self._store.async_get_data() or {}
store["cache"] = self._cache
await self._store.async_set_data(store)
else:
_LOGGER.warning(f"Skip persisting cache; no store available to write to")


def _getModified(self, entity: StuderEntityData) -> Any:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/studer_xcom/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"issue_tracker": "https://github.com/ankohanse/hass-studer-xcom/issues",
"loggers": ["custom_components.studer_xcom"],
"requirements": ["aioxcom>=1.6.1"],
"version": "2024.11.4"
"version": "2024.12.2"
}

0 comments on commit 741fb20

Please sign in to comment.