feat(nodes): invocation cache reports disabled if max size is 0

This commit is contained in:
psychedelicious 2023-09-21 22:12:11 +10:00 committed by Kent Keirsey
parent 7ac99d6bc3
commit fa54974bff
3 changed files with 9 additions and 5 deletions

View File

@ -75,16 +75,20 @@ class MemoryInvocationCache(InvocationCacheBase):
return hash(invocation.json(exclude={"id"}))
def disable(self) -> None:
if self.__max_cache_size == 0:
return
self.__disabled = True
def enable(self) -> None:
if self.__max_cache_size == 0:
return
self.__disabled = False
def get_status(self) -> InvocationCacheStatus:
return InvocationCacheStatus(
hits=self.__hits,
misses=self.__misses,
enabled=not self.__disabled,
enabled=not self.__disabled and self.__max_cache_size > 0,
size=len(self.__cache),
max_size=self.__max_cache_size,
)

View File

@ -17,8 +17,8 @@ export const useDisableInvocationCache = () => {
});
const isDisabled = useMemo(
() => !cacheStatus?.enabled || !isConnected,
[cacheStatus?.enabled, isConnected]
() => !cacheStatus?.enabled || !isConnected || cacheStatus?.max_size === 0,
[cacheStatus?.enabled, cacheStatus?.max_size, isConnected]
);
const disableInvocationCache = useCallback(async () => {

View File

@ -17,8 +17,8 @@ export const useEnableInvocationCache = () => {
});
const isDisabled = useMemo(
() => cacheStatus?.enabled || !isConnected,
[cacheStatus?.enabled, isConnected]
() => cacheStatus?.enabled || !isConnected || cacheStatus?.max_size === 0,
[cacheStatus?.enabled, cacheStatus?.max_size, isConnected]
);
const enableInvocationCache = useCallback(async () => {