diff --git a/CHANGELOG.md b/CHANGELOG.md index e2fd107..7542f68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +* [v1.62.0](https://github.com/newt-sc/a4kStreaming/releases/tag/plugin.video.a4kstreaming%2Fplugin.video.a4kstreaming-1.62.0): + * Reduce cache ttl to 5s and remove cache auto refresh + * [v1.61.0](https://github.com/newt-sc/a4kStreaming/releases/tag/plugin.video.a4kstreaming%2Fplugin.video.a4kstreaming-1.61.0): * Fix trailers diff --git a/a4kStreaming/lib/database.py b/a4kStreaming/lib/database.py index f302bf1..8c6c4cf 100644 --- a/a4kStreaming/lib/database.py +++ b/a4kStreaming/lib/database.py @@ -22,13 +22,20 @@ def __cache_get(key): return {} def __cache_check(key): - path = __cache_key_path(key) - return os.path.exists(path) + try: + path = __cache_key_path(key) + if os.path.exists(path): + ttl = os.path.getmtime(path) + if time.time() - ttl < 5: + return True + os.remove(path) + except: + pass def __cache_cleanup(): try: - # while temp dir bigger than 500MiB, remove files sorted by age (oldest first) - max_size = 500 * 1024 * 1024 + # while temp dir bigger than 5MiB, remove files sorted by age (oldest first) + max_size = 5 * 1024 * 1024 files = [] size = 0 diff --git a/a4kStreaming/lib/request.py b/a4kStreaming/lib/request.py index 4efd5c5..2fa396b 100644 --- a/a4kStreaming/lib/request.py +++ b/a4kStreaming/lib/request.py @@ -48,14 +48,6 @@ def execute(core, request, cache=True): response.text = '' response.content = core.db.get(request_hash) response.status_code = 200 - - def refresh(): - response = session.request(verify=False, **request) - if response.status_code == 200: - core.logger.debug('Cache refresh: %s' % request_hash) - core.db.set(request_hash, response.content) - - core.threading.Thread(target=refresh).start() else: if cache: core.logger.debug('Cache miss: %s' % request_hash) diff --git a/addon.xml b/addon.xml index 36613de..a129613 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ @@ -32,6 +32,9 @@ Designed for low-end devices and Estuary skin. screenshot-06.jpg +[v1.62.0]: + * Reduce cache ttl to 5s and remove cache auto refresh + [v1.61.0]: * Fix trailers diff --git a/packages/addons.xml b/packages/addons.xml index 61ae288..e403afa 100644 --- a/packages/addons.xml +++ b/packages/addons.xml @@ -4,7 +4,7 @@ @@ -35,6 +35,9 @@ Designed for low-end devices and Estuary skin. screenshot-06.jpg +[v1.62.0]: + * Reduce cache ttl to 5s and remove cache auto refresh + [v1.61.0]: * Fix trailers diff --git a/packages/addons.xml.crc b/packages/addons.xml.crc index 78b1901..7c45a00 100644 --- a/packages/addons.xml.crc +++ b/packages/addons.xml.crc @@ -1 +1 @@ -f36bf5c9fe64754387df68028976c6e9f3de2d4d \ No newline at end of file +0510d1eba3846ce5f8607255b16f50be8d5db09b \ No newline at end of file