Closed powerli2002 closed 1 week ago
We appreciate your contribution, in our work, due to considerations of context and time, we opted not to implement the eviction_manager in detail within the open-source project. Consequently, your efforts provide a supplement to this project and align with the gptcache in certain aspects, which is what we hope to see.
Regarding the table name "cache_codegpt_answer," this was an oversight during our initial submissions, which we have fixed. Therefore, I have modified the table name in your code.
Once again, thank you for your contributions to the ModelCache project. Best wishes!
Abstract:
Problems Solved:
mark_deleted
method did not perform a soft delete but instead directly deleted the data bymark_id
.cache_codegpt_answer
table in the database did not have anis_deleted
field, making soft deletes impossible.modelcache_llm_answer
, while MySQL used thecache_codegpt_answer
table.self._vector_base.delete
method did not specify a model, making it impossible to delete the corresponding table during cache eviction.Modifications:
Implemented true soft delete:
modelcache\manager\scalar_data\sql_storage.py
:mark_deleted
method to mark theis_deleted
field as 1 (pending deletion).clear_deleted_data
method.count
method.Database modifications:
reference_doc\create_table.sql
frommodelcache_llm_answer
tocache_codegpt_answer
, or alternatively modified thetable_name
in the code.is_deleted
field tocache_codegpt_answer
, with -1 for pending deletion and 0 for not deleted (consistent with GPTCache).Implemented the cache eviction strategy, defaulting to LRU:
modelcache\manager\eviction_manager.py
, added amodel
parameter to thedelete
method to enable deletion of corresponding IDs in Mivuls.Considering that I only implemented the method for MySQL, I did not directly apply the cache eviction strategy in
data_manager.py
. To use the cache eviction strategy (MySQL + Mivuls), you need to add the following inmodelcache\manager\data_manager.py
:The definition of
self.model
is to inform the data manager which model's table is being processed during insertion. The code refers to gptcache and tries to be functionally consistent.This method has been locally verified to be feasible, with both the eviction strategy and soft delete functioning properly.
Please feel free to contact me if there are any issues with my changes.