File size: 475 Bytes
fea9f64 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
from functools import lru_cache
import hashlib
import json
class ModelCache:
def __init__(self, cache_size=128):
self.cache_size = cache_size
@lru_cache(maxsize=128)
def cache_result(self, input_key, result):
return result
def get_cache_key(self, audio_data):
# Create hash of audio data for cache key
return hashlib.md5(audio_data).hexdigest()
def clear_cache(self):
self.cache_result.cache_clear() |