statcache

package
v1.117.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2024 License: AGPL-3.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCachedStatBlobStore

func NewCachedStatBlobStore(log *zap.Logger, cache Cache, delegate blobstore.Blobs) blobstore.Blobs

NewCachedStatBlobStore creates a new cached blobstore.

Types

type BadgerCache

type BadgerCache struct {
	// contains filtered or unexported fields
}

BadgerCache implements Cache with saving file size / mod time to badger database.

func NewBadgerCache

func NewBadgerCache(log *zap.Logger, dir string) (*BadgerCache, error)

NewBadgerCache creates a new BadgerCache.

func (*BadgerCache) Close

func (b *BadgerCache) Close() error

Close implements Cache.

func (*BadgerCache) Delete

func (b *BadgerCache) Delete(ctx context.Context, namespace []byte, key []byte) error

Delete implements Cache.

func (*BadgerCache) Get

func (b *BadgerCache) Get(ctx context.Context, namespace []byte, key []byte) (blobstore.FileInfo, bool, error)

Get implements Cache.

func (*BadgerCache) Set

func (b *BadgerCache) Set(ctx context.Context, namespace []byte, key []byte, value blobstore.FileInfo) error

Set implements Cache.

type BlobInfo

type BlobInfo struct {
	blobstore.BlobInfo
	// contains filtered or unexported fields
}

BlobInfo is the cached version of blobstore.Blobinfo.

func (BlobInfo) Stat

Stat implements blobstore.Blobinfo.

type Cache

type Cache interface {
	Get(ctx context.Context, namespace []byte, key []byte) (blobstore.FileInfo, bool, error)
	Set(ctx context.Context, namespace []byte, key []byte, value blobstore.FileInfo) error
	Delete(ctx context.Context, namespace []byte, key []byte) error
	Close() error
}

Cache can store file metadata (size/mod time) and make it available (quickly).

type CachedStatBlobstore

type CachedStatBlobstore struct {
	blobstore.Blobs
	// contains filtered or unexported fields
}

CachedStatBlobstore implements a blob store, but also manages an external cache for file metadata.

func (*CachedStatBlobstore) Delete

Delete implements blobstore.Blobs.

func (*CachedStatBlobstore) DeleteWithStorageFormat

func (s *CachedStatBlobstore) DeleteWithStorageFormat(ctx context.Context, ref blobstore.BlobRef, formatVer blobstore.FormatVersion, sizeHint int64) error

DeleteWithStorageFormat implements blobstore.Blobs.

func (*CachedStatBlobstore) EmptyTrash

func (s *CachedStatBlobstore) EmptyTrash(ctx context.Context, namespace []byte, trashedBefore time.Time) (int64, [][]byte, error)

EmptyTrash implements blobstore.Blobs.

func (*CachedStatBlobstore) Stat

Stat implements blobstore.Blobs.

func (*CachedStatBlobstore) StatWithStorageFormat

func (s *CachedStatBlobstore) StatWithStorageFormat(ctx context.Context, ref blobstore.BlobRef, formatVer blobstore.FormatVersion) (blobstore.BlobInfo, error)

StatWithStorageFormat implements blobstore.Blobs.

func (*CachedStatBlobstore) WalkNamespace

func (s *CachedStatBlobstore) WalkNamespace(ctx context.Context, namespace []byte, skipPrefixFn blobstore.SkipPrefixFn, walkFunc func(blobstore.BlobInfo) error) error

WalkNamespace implements blobstore.Blobs.

type FileInfo

type FileInfo struct {
	// contains filtered or unexported fields
}

FileInfo is a simple implementation of blobstore.FileInfo.

func (FileInfo) ModTime

func (f FileInfo) ModTime() time.Time

ModTime implements blobstore.FileInfo.

func (FileInfo) Size

func (f FileInfo) Size() int64

Size implements blobstore.FileInfo.

type Lie

type Lie struct {
}

Lie is a cache implementation with returns with fake values. Do not use in production. Only for performance testing.

func (Lie) Close

func (l Lie) Close() error

Close implements Cache.

func (Lie) Delete

func (l Lie) Delete(ctx context.Context, namespace []byte, key []byte) error

Delete implements Cache.

func (Lie) Get

func (l Lie) Get(ctx context.Context, namespace []byte, key []byte) (blobstore.FileInfo, bool, error)

Get implements Cache.

func (Lie) Set

func (l Lie) Set(ctx context.Context, namespace []byte, key []byte, value blobstore.FileInfo) error

Set implements Cache.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL