leideng/QCFuse / srt /mem_cache /evict_policy.py
leideng's picture
download
raw
1.01 kB
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Tuple, Union
if TYPE_CHECKING:
from sglang.srt.mem_cache.radix_cache import TreeNode
class EvictionStrategy(ABC):
@abstractmethod
def get_priority(self, node: "TreeNode") -> Union[float, Tuple]:
pass
class LRUStrategy(EvictionStrategy):
def get_priority(self, node: "TreeNode") -> float:
return node.last_access_time
class LFUStrategy(EvictionStrategy):
def get_priority(self, node: "TreeNode") -> Tuple[int, float]:
return (node.hit_count, node.last_access_time)
class FIFOStrategy(EvictionStrategy):
def get_priority(self, node: "TreeNode") -> float:
return node.creation_time
class MRUStrategy(EvictionStrategy):
def get_priority(self, node: "TreeNode") -> float:
return -node.last_access_time
class FILOStrategy(EvictionStrategy):
def get_priority(self, node: "TreeNode") -> float:
return -node.creation_time

Xet Storage Details

Size:
1.01 kB
·
Xet hash:
381915ad47bb60084373de96c943c86ffe87a3b10aa95abaf9224266c2b94db2

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.