package cache import ( "context" "forge.cadoles.com/arcad/edge/pkg/storage" "github.com/allegro/bigcache/v3" "github.com/pkg/errors" ) type BlobStore struct { store storage.BlobStore cache *bigcache.BigCache } // DeleteBucket implements storage.BlobStore. func (s *BlobStore) DeleteBucket(ctx context.Context, name string) error { if err := s.store.DeleteBucket(ctx, name); err != nil { return errors.WithStack(err) } return nil } // ListBuckets implements storage.BlobStore. func (s *BlobStore) ListBuckets(ctx context.Context) ([]string, error) { buckets, err := s.store.ListBuckets(ctx) if err != nil { return nil, errors.WithStack(err) } return buckets, nil } // OpenBucket implements storage.BlobStore. func (s *BlobStore) OpenBucket(ctx context.Context, name string) (storage.BlobBucket, error) { bucket, err := s.store.OpenBucket(ctx, name) if err != nil { return nil, errors.WithStack(err) } return &BlobBucket{ bucket: bucket, cache: s.cache, }, nil } func NewBlobStore(store storage.BlobStore, cache *bigcache.BigCache) *BlobStore { return &BlobStore{ store: store, cache: cache, } } var _ storage.BlobStore = &BlobStore{}