Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
Kilo59 committed Apr 27, 2020
commit c97476ef4ffe1425f944f3ead8950318204cd5fd
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Port to serve app on.
PORT = 5000
LOCAL_REDIS_URL = redis://username:password@localhost:6379
LOCAL_REDIS_URL = redis://localhost:6379
2 changes: 2 additions & 0 deletions app/caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def get_cache(namespace) -> Union[aiocache.RedisCache, aiocache.SimpleMemoryCach


async def check_cache(data_id: str, namespace: str = None):
"""Check the data of a cache given an id."""
cache = get_cache(namespace)
result = await cache.get(data_id, None)
LOGGER.info(f"{data_id} cache pulled")
Expand All @@ -44,6 +45,7 @@ async def check_cache(data_id: str, namespace: str = None):


async def load_cache(data_id: str, data, namespace: str = None, cache_life: int = 3600):
"""Load data into the cache."""
cache = get_cache(namespace)
await cache.set(data_id, data, ttl=cache_life)
LOGGER.info(f"{data_id} cache loaded")
Expand Down
2 changes: 1 addition & 1 deletion app/services/location/jhu.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from asyncache import cached
from cachetools import TTLCache

from ...caches import check_cache, get_cache, load_cache
from ...caches import check_cache, load_cache
from ...coordinates import Coordinates
from ...location import TimelinedLocation
from ...timeline import Timeline
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
-i https://pypi.org/simple
aiocache[redis]==0.11.1
aiohttp==3.6.2
aioredis==1.3.1
async-timeout==3.0.1
asyncache==0.1.1
attrs==19.3.0
Expand All @@ -11,6 +13,7 @@ dataclasses==0.6 ; python_version < '3.7'
fastapi==0.54.1
gunicorn==20.0.4
h11==0.9.0
hiredis==1.0.1
httptools==0.1.1 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
idna-ssl==1.1.0 ; python_version < '3.7'
idna==2.9
Expand Down