Skip to content

Commit

Permalink
fix cache
Browse files Browse the repository at this point in the history
  • Loading branch information
vanchaxy committed Dec 10, 2024
1 parent 19aa4b1 commit 1763eb6
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ app = 'plexio'
primary_region = 'iad'

[build]
image = 'ghcr.io/vanchaxy/plexio:0.1.11'
image = 'ghcr.io/vanchaxy/plexio:0.1.12'

[env]
CACHE_TYPE = 'redis'
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "frontend",
"private": true,
"version": "0.1.11",
"version": "0.1.12",
"type": "module",
"scripts": {
"dev": "vite --host",
Expand Down
2 changes: 1 addition & 1 deletion plexio/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.11'
__version__ = '0.1.12'
4 changes: 3 additions & 1 deletion plexio/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from redis.asyncio import Redis
from redis.exceptions import ConnectionError as RedisConnectionError

PLEX_CACHE_TTL = 24 * 60 * 60


def init_cache(settings):
if settings.cache_type is CacheType.memory:
Expand Down Expand Up @@ -57,7 +59,7 @@ def __init__(self, redis_url):
async def set(self, key, value):
for _ in range(RedisCache.RETRY_TIMES):
try:
await self._redis.set(key, value)
await self._redis.set(key, value, ex=PLEX_CACHE_TTL)
except RedisConnectionError:
await asyncio.sleep(RedisCache.RETRY_BACKOFF_SEC)

Expand Down
4 changes: 1 addition & 3 deletions plexio/plex/media_server_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from plexio.plex.utils import get_json
from plexio.settings import settings

PLEX_CACHE_TTL = 24 * 60 * 60

SORT_OPTIONS = {
'Title': 'title',
'Title (desc)': 'title:desc',
Expand Down Expand Up @@ -247,5 +245,5 @@ async def stremio_to_plex_id(
return None

if plex_id:
await cache.set(stremio_id, plex_id, ex=PLEX_CACHE_TTL)
await cache.set(stremio_id, plex_id)
return plex_id

0 comments on commit 1763eb6

Please sign in to comment.