MCPcopy
hub / github.com/daptin/daptin / InitSubsiteCache

Function InitSubsiteCache

server/subsite_cache.go:286–311  ·  view source on GitHub ↗

InitSubsiteCache initializes the Olric cache for subsites

(client *olric.EmbeddedClient)

Source from the content-addressed store, hash-verified

284
285// InitSubsiteCache initializes the Olric cache for subsites
286func InitSubsiteCache(client *olric.EmbeddedClient) error {
287 subsiteCacheMutex.Lock()
288 defer subsiteCacheMutex.Unlock()
289
290 if subsiteCacheInitialized {
291 return nil
292 }
293
294 if client == nil {
295 return fmt.Errorf("olric client is nil")
296 }
297
298 olricClient = client
299 var err error
300 SubsiteCache, err = client.NewDMap(CacheConfig.Namespace)
301 if err != nil {
302 return fmt.Errorf("failed to create Olric DMap for subsite cache: %v", err)
303 }
304
305 // Start periodic metrics logging
306 go logCacheMetricsPeriodically()
307
308 log.Infof("Subsite cache initialized with max entry size: %d KB", CacheConfig.MaxEntrySize/1024)
309 subsiteCacheInitialized = true
310 return nil
311}
312
313// addToCache adds an entry to the cache with TTL
314func addToCache(cacheKey string, entry *SubsiteCacheEntry) error {

Callers 1

CreateSubSitesFunction · 0.85

Calls 1

Tested by

no test coverage detected