1
0
mirror of https://github.com/ltcptgeneral/cs239-caching.git synced 2025-03-30 03:35:18 +00:00

add individual config files for each strategy,

config file path can be specified as the second argument
This commit is contained in:
Arthur Lu 2025-02-28 19:17:44 +00:00 committed by root
parent e9b1128826
commit f7903f4fea
6 changed files with 18 additions and 1 deletions

@ -1,7 +1,8 @@
import os
import yaml
import sys
CONFIG_FILE = "config.yaml"
CONFIG_FILE = sys.argv[1]
def load_config():
with open(CONFIG_FILE, "r") as f:

4
app/config_baseline.yaml Normal file

@ -0,0 +1,4 @@
cache_strategy: "Baseline" # Change this to "Prefetch" or "Tiered" or "Seive"
cache_limit: 10
l2_cache_limit: 100
db_file: "llmData_sns.json" # Change this to the name of any json file within the "database/datastore" folder

4
app/config_seive.yaml Normal file

@ -0,0 +1,4 @@
cache_strategy: "Seive" # Change this to "Prefetch" or "Tiered" or "Seive"
cache_limit: 10
l2_cache_limit: 100
db_file: "llmData_sns.json" # Change this to the name of any json file within the "database/datastore" folder

4
app/config_tiered.yaml Normal file

@ -0,0 +1,4 @@
cache_strategy: "Tiered" # Change this to "Prefetch" or "Tiered" or "Seive"
cache_limit: 10
l2_cache_limit: 100
db_file: "llmData_sns.json" # Change this to the name of any json file within the "database/datastore" folder

@ -11,12 +11,16 @@ app = FastAPI()
# Initialize cache based on strategy from config.yaml or environment variable
if CACHE_STRATEGY == "Baseline":
print("Using baseline cache strategy")
cache = BaselineCache(limit=CACHE_LIMIT)
elif CACHE_STRATEGY == "Prefetch":
print("Using prefetch cache strategy")
cache = PrefetchCache(limit=CACHE_LIMIT)
elif CACHE_STRATEGY == "Tiered":
print("Using tiered cache strategy")
cache = TieredCache(limit=CACHE_LIMIT, l2_limit=L2_CACHE_LIMIT)
elif CACHE_STRATEGY == "Seive":
print("Using seive cache strategy")
cache = SeiveCache(limit=CACHE_LIMIT)
else:
raise ValueError(f"Invalid CACHE_STRATEGY: {CACHE_STRATEGY}")