MCPcopy
hub / github.com/daptin/daptin / NewFileCache

Function NewFileCache

server/cache/file_cache.go:266–287  ·  view source on GitHub ↗

NewFileCache creates a new file cache using Olric

(olricClient *olric.EmbeddedClient, namespace string)

Source from the content-addressed store, hash-verified

264
265// NewFileCache creates a new file cache using Olric
266func NewFileCache(olricClient *olric.EmbeddedClient, namespace string) (*FileCache, error) {
267 if olricClient == nil {
268 return nil, fmt.Errorf("olric client is nil")
269 }
270
271 dmap, err := olricClient.NewDMap(namespace)
272 if err != nil {
273 return nil, fmt.Errorf("failed to create Olric DMap for assets cache: %v", err)
274 }
275
276 fc := &FileCache{
277 cache: dmap,
278 workerPool: make(chan struct{}, WorkerPoolSize),
279 }
280
281 // Initialize worker pool
282 for i := 0; i < WorkerPoolSize; i++ {
283 fc.workerPool <- struct{}{}
284 }
285
286 return fc, nil
287}
288
289// CompressData compresses data using gzip
290func CompressData(data []byte) ([]byte, error) {

Callers 2

CreateDbAssetHandlerFunction · 0.92
CreateTemplateHooksFunction · 0.92

Calls 1

makeFunction · 0.85

Tested by

no test coverage detected