Skip to content

Commit

Permalink
Fix cache (#278)
Browse files Browse the repository at this point in the history
Add inference cache

---------

Signed-off-by: s0nicboOm <i.kushalbatra@gmail.com>
  • Loading branch information
s0nicboOm authored Aug 31, 2023
1 parent 3581a82 commit ac08953
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion numalogic/udfs/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

# TODO: move to config
LOCAL_CACHE_TTL = int(os.getenv("LOCAL_CACHE_TTL", "3600"))
LOCAL_CACHE_SIZE = int(os.getenv("LOCAL_CACHE_SIZE", "10000"))


class InferenceUDF(NumalogicUDF):
Expand All @@ -35,7 +36,8 @@ class InferenceUDF(NumalogicUDF):
def __init__(self, r_client: redis_client_t, pl_conf: Optional[PipelineConf] = None):
super().__init__(is_async=False)
self.model_registry = RedisRegistry(
client=r_client, cache_registry=LocalLRUCache(ttl=LOCAL_CACHE_TTL)
client=r_client,
cache_registry=LocalLRUCache(ttl=LOCAL_CACHE_TTL, cachesize=LOCAL_CACHE_SIZE),
)
self.pl_conf = pl_conf or PipelineConf()

Expand Down

0 comments on commit ac08953

Please sign in to comment.