Files
sglang/python/sglang/srt/mem_cache/base_prefix_cache.py
2024-08-11 02:44:59 -07:00

49 lines
924 B
Python

from abc import ABC, abstractmethod
from typing import Callable
class BasePrefixCache(ABC):
"""Cache can be indexed by either rid or key."""
@abstractmethod
def reset(self):
pass
@abstractmethod
def match_prefix(self, **kwargs):
pass
@abstractmethod
def insert(self, **kwargs):
pass
@abstractmethod
def cache_finished_req(self, **kwargs):
pass
@abstractmethod
def cache_unfinished_req(self, **kwargs):
pass
@abstractmethod
def evict(self, num_tokens: int, evict_callback: Callable):
pass
@abstractmethod
def inc_lock_ref(self, node):
pass
@abstractmethod
def dec_lock_ref(self, node):
pass
@abstractmethod
def evictable_size(self):
pass
def total_size(self):
raise NotImplementedError()
def pretty_print(self):
raise NotImplementedError()