Mercurial > personal > weather-server
diff weather_server/locations.py @ 31:9bc3687e1e5e
logfile: Add an index, and don't keep everything in RAM.
- Adds index BSON file, updated upon writing.
- Limits amount of data in RAM.
- Gracefully handles writes that don't update index.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Tue, 07 Jul 2020 19:51:30 -0400 |
parents | 7def5611895b |
children | 2f3473416c11 |
line wrap: on
line diff
--- a/weather_server/locations.py Tue May 19 10:15:29 2020 -0400 +++ b/weather_server/locations.py Tue Jul 07 19:51:30 2020 -0400 @@ -48,10 +48,10 @@ @property def entries(self) -> t.Iterable[t.Dict[str, object]]: - return self.logger.data + return self.logger.cached_data def latest(self) -> t.Optional[types.Reading]: - most_recent = reversed(self.logger.data) + most_recent = reversed(self.logger.cached_data) for entry in most_recent: try: return types.Reading.from_dict(entry)