-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chengfangyin2
committed
Dec 8, 2023
1 parent
3a70edc
commit c71599c
Showing
20 changed files
with
91 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import Type, Dict | ||
|
||
|
||
class Serializable(ABC): | ||
@abstractmethod | ||
def serialize(self) -> bytes: | ||
"""Convert the object into bytes for storage or transmission. | ||
Returns: | ||
bytes: The byte array after serialization | ||
""" | ||
|
||
@abstractmethod | ||
def to_dict(self) -> Dict: | ||
"""Convert the object's state to a dictionary.""" | ||
|
||
|
||
class Serializer(ABC): | ||
"""The serializer abstract class for serializing cache keys and values.""" | ||
|
||
@abstractmethod | ||
def serialize(self, obj: Serializable) -> bytes: | ||
"""Serialize a cache object. | ||
Args: | ||
obj (Serializable): The object to serialize | ||
""" | ||
|
||
@abstractmethod | ||
def deserialize(self, data: bytes, cls: Type[Serializable]) -> Serializable: | ||
"""Deserialize data back into a cache object of the specified type. | ||
Args: | ||
data (bytes): The byte array to deserialize | ||
cls (Type[Serializable]): The type of current object | ||
Returns: | ||
Serializable: The serializable object | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from dbgpt.storage.cache.manager import CacheManager, initialize_cache | ||
from dbgpt.storage.cache.storage.base import MemoryCacheStorage | ||
from dbgpt.storage.cache.llm_cache import LLMCacheKey, LLMCacheValue, LLMCacheClient | ||
|
||
__all__ = [ | ||
"LLMCacheKey", | ||
"LLMCacheValue", | ||
"LLMCacheClient", | ||
"CacheManager", | ||
"initialize_cache", | ||
"MemoryCacheStorage", | ||
] |
File renamed without changes.
9 changes: 3 additions & 6 deletions
9
dbgpt/util/cache/llm_cache.py → dbgpt/storage/cache/llm_cache.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
10 changes: 4 additions & 6 deletions
10
...t/util/cache/storage/disk/disk_storage.py → ...torage/cache/storage/disk/disk_storage.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters