MCPcopy Create free account
hub / github.com/AsyncFuncAI/deepwiki-open / save_wiki_cache

Function save_wiki_cache

api/api.py:426–457  ·  view source on GitHub ↗

Saves wiki cache data to the file system.

(data: WikiCacheRequest)

Source from the content-addressed store, hash-verified

424 return None
425
426async def save_wiki_cache(data: WikiCacheRequest) -> bool:
427 """Saves wiki cache data to the file system."""
428 cache_path = get_wiki_cache_path(data.repo.owner, data.repo.repo, data.repo.type, data.language)
429 logger.info(f"Attempting to save wiki cache. Path: {cache_path}")
430 try:
431 payload = WikiCacheData(
432 wiki_structure=data.wiki_structure,
433 generated_pages=data.generated_pages,
434 repo=data.repo,
435 provider=data.provider,
436 model=data.model
437 )
438 # Log size of data to be cached for debugging (avoid logging full content if large)
439 try:
440 payload_json = payload.model_dump_json()
441 payload_size = len(payload_json.encode('utf-8'))
442 logger.info(f"Payload prepared for caching. Size: {payload_size} bytes.")
443 except Exception as ser_e:
444 logger.warning(f"Could not serialize payload for size logging: {ser_e}")
445
446
447 logger.info(f"Writing cache file to: {cache_path}")
448 with open(cache_path, 'w', encoding='utf-8') as f:
449 json.dump(payload.model_dump(), f, indent=2)
450 logger.info(f"Wiki cache successfully saved to {cache_path}")
451 return True
452 except IOError as e:
453 logger.error(f"IOError saving wiki cache to {cache_path}: {e.strerror} (errno: {e.errno})", exc_info=True)
454 return False
455 except Exception as e:
456 logger.error(f"Unexpected error saving wiki cache to {cache_path}: {e}", exc_info=True)
457 return False
458
459# --- Wiki Cache API Endpoints ---
460

Callers 1

store_wiki_cacheFunction · 0.85

Calls 2

get_wiki_cache_pathFunction · 0.85
WikiCacheDataClass · 0.70

Tested by

no test coverage detected