switch to cachew

This commit is contained in:
Dima Gerasimov 2019-07-27 12:12:59 +01:00
parent 8bbcf6aa1d
commit e1a251d88a
2 changed files with 4 additions and 8 deletions

View file

@ -12,7 +12,8 @@ import pytz
from kython import kompress
from kython.kcache import make_dbcache, mtime_hash
from cachew import cachew, mtime_hash
# pipe install geopy
@ -38,8 +39,6 @@ class Location(NamedTuple):
alt: Optional[float]
tag: Tag
dbcache = make_dbcache(CACHE_PATH, hashf=mtime_hash, type_=Location, chunk_by=10000, logger=get_logger())
def tagger(dt: datetime, point: geopy.Point) -> Tag:
TAGS = [
@ -87,8 +86,7 @@ def _iter_locations_fo(fo, start, stop) -> Iterator[Location]:
)
# TODO hope they are sorted...
# TODO that could also serve as basis for tz provider
@dbcache
@cachew(CACHE_PATH, hashf=mtime_hash, cls=Location, chunk_by=10000, logger=get_logger())
def _iter_locations(path: Path, start=0, stop=None) -> Iterator[Location]:
if path.suffix == '.json':
ctx = path.open('r')

View file

@ -4,13 +4,11 @@ import logging
from location import get_logger, get_locations, iter_locations, get_groups
from kython.klogging import setup_logzero
from kython.kcache import get_kcache_logger
def main():
logger = get_logger()
setup_logzero(logger, level=logging.INFO)
setup_logzero(get_kcache_logger(), level=logging.DEBUG)
setup_logzero(logger, level=logging.DEBUG)
if len(sys.argv) > 1: