NewFileCache creates a new file cache using Olric
(olricClient *olric.EmbeddedClient, namespace string)
| 264 | |
| 265 | // NewFileCache creates a new file cache using Olric |
| 266 | func 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 |
| 290 | func CompressData(data []byte) ([]byte, error) { |
no test coverage detected