mirror of
https://github.com/ltcptgeneral/cs239-caching.git
synced 2025-04-01 12:33:25 +00:00
add individual config files for each strategy,
config file path can be specified as the second argument
This commit is contained in:
parent
e9b1128826
commit
f7903f4fea
@ -1,7 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
import sys
|
||||||
|
|
||||||
CONFIG_FILE = "config.yaml"
|
CONFIG_FILE = sys.argv[1]
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
with open(CONFIG_FILE, "r") as f:
|
with open(CONFIG_FILE, "r") as f:
|
||||||
|
4
app/config_baseline.yaml
Normal file
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
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
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
|
# Initialize cache based on strategy from config.yaml or environment variable
|
||||||
if CACHE_STRATEGY == "Baseline":
|
if CACHE_STRATEGY == "Baseline":
|
||||||
|
print("Using baseline cache strategy")
|
||||||
cache = BaselineCache(limit=CACHE_LIMIT)
|
cache = BaselineCache(limit=CACHE_LIMIT)
|
||||||
elif CACHE_STRATEGY == "Prefetch":
|
elif CACHE_STRATEGY == "Prefetch":
|
||||||
|
print("Using prefetch cache strategy")
|
||||||
cache = PrefetchCache(limit=CACHE_LIMIT)
|
cache = PrefetchCache(limit=CACHE_LIMIT)
|
||||||
elif CACHE_STRATEGY == "Tiered":
|
elif CACHE_STRATEGY == "Tiered":
|
||||||
|
print("Using tiered cache strategy")
|
||||||
cache = TieredCache(limit=CACHE_LIMIT, l2_limit=L2_CACHE_LIMIT)
|
cache = TieredCache(limit=CACHE_LIMIT, l2_limit=L2_CACHE_LIMIT)
|
||||||
elif CACHE_STRATEGY == "Seive":
|
elif CACHE_STRATEGY == "Seive":
|
||||||
|
print("Using seive cache strategy")
|
||||||
cache = SeiveCache(limit=CACHE_LIMIT)
|
cache = SeiveCache(limit=CACHE_LIMIT)
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Invalid CACHE_STRATEGY: {CACHE_STRATEGY}")
|
raise ValueError(f"Invalid CACHE_STRATEGY: {CACHE_STRATEGY}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user