Spaces:
Running
Running
Update document_generator_v2.py
Browse files- document_generator_v2.py +2 -2
document_generator_v2.py
CHANGED
@@ -649,7 +649,7 @@ class CacheItem(BaseModel):
|
|
649 |
async def set_cache(item: CacheItem):
|
650 |
try:
|
651 |
# Set the cache with a default expiration of 1 hour (3600 seconds)
|
652 |
-
await FastAPICache.set(item.key, item.value, expire=3600)
|
653 |
return {"message": f"Cache set for key: {item.key}"}
|
654 |
except Exception as e:
|
655 |
raise HTTPException(status_code=500, detail=f"Failed to set cache: {str(e)}")
|
@@ -657,7 +657,7 @@ async def set_cache(item: CacheItem):
|
|
657 |
@router.get("/get-cache/{key}")
|
658 |
async def get_cache(key: str):
|
659 |
try:
|
660 |
-
value = await FastAPICache.get(key)
|
661 |
if value is None:
|
662 |
raise HTTPException(status_code=404, detail=f"No cache found for key: {key}")
|
663 |
return {"key": key, "value": value}
|
|
|
649 |
async def set_cache(item: CacheItem):
|
650 |
try:
|
651 |
# Set the cache with a default expiration of 1 hour (3600 seconds)
|
652 |
+
await FastAPICache.get_backend().set(item.key, item.value, expire=3600)
|
653 |
return {"message": f"Cache set for key: {item.key}"}
|
654 |
except Exception as e:
|
655 |
raise HTTPException(status_code=500, detail=f"Failed to set cache: {str(e)}")
|
|
|
657 |
@router.get("/get-cache/{key}")
|
658 |
async def get_cache(key: str):
|
659 |
try:
|
660 |
+
value = await FastAPICache.get_backend().get(key)
|
661 |
if value is None:
|
662 |
raise HTTPException(status_code=404, detail=f"No cache found for key: {key}")
|
663 |
return {"key": key, "value": value}
|