Documentation ¶
Index ¶
- Constants
- func GenerateCacheFromConfig(cacheCfg *config.CacheConfig) interfaces.Cache
- func NewComposedCache(inner, outer interfaces.Cache, mode CacheMode) interfaces.Cache
- func NewDiskCache(cfg *config.Cache) interfaces.Cache
- func NewMemoryCache(cfg *config.Cache) interfaces.Cache
- func NewRedisCache(cfg *config.Cache) interfaces.Cache
- type CacheMode
- type ComposedCache
- func (c *ComposedCache) Check(ctx context.Context) error
- func (c *ComposedCache) Contains(ctx context.Context, d *repb.Digest) (bool, error)
- func (c *ComposedCache) Delete(ctx context.Context, d *repb.Digest) error
- func (c *ComposedCache) FindMissing(ctx context.Context, digests []*repb.Digest) ([]*repb.Digest, error)
- func (c *ComposedCache) Get(ctx context.Context, d *repb.Digest) ([]byte, error)
- func (c *ComposedCache) GetMulti(ctx context.Context, digests []*repb.Digest) (map[*repb.Digest][]byte, error)
- func (c *ComposedCache) Reader(ctx context.Context, d *repb.Digest, offset int64) (io.ReadCloser, error)
- func (c *ComposedCache) Set(ctx context.Context, d *repb.Digest, data []byte) error
- func (c *ComposedCache) SetMulti(ctx context.Context, kvs map[*repb.Digest][]byte) error
- func (c *ComposedCache) Size() int64
- func (c *ComposedCache) WithIsolation(ctx context.Context, cacheType interfaces.CacheType, remoteInstanceName string) (interfaces.Cache, error)
- func (c *ComposedCache) Writer(ctx context.Context, d *repb.Digest) (io.WriteCloser, error)
- type DiskCache
- func (c *DiskCache) Check(ctx context.Context) error
- func (c *DiskCache) Contains(ctx context.Context, d *repb.Digest) (bool, error)
- func (c *DiskCache) Delete(ctx context.Context, d *repb.Digest) error
- func (c *DiskCache) FindMissing(ctx context.Context, digests []*repb.Digest) ([]*repb.Digest, error)
- func (c *DiskCache) Get(ctx context.Context, d *repb.Digest) ([]byte, error)
- func (c *DiskCache) GetMulti(ctx context.Context, digests []*repb.Digest) (map[*repb.Digest][]byte, error)
- func (c *DiskCache) Reader(ctx context.Context, d *repb.Digest, offset int64) (io.ReadCloser, error)
- func (c *DiskCache) Set(ctx context.Context, d *repb.Digest, data []byte) error
- func (c *DiskCache) SetMulti(ctx context.Context, kvs map[*repb.Digest][]byte) error
- func (c *DiskCache) Size() int64
- func (c *DiskCache) WithIsolation(ctx context.Context, cacheType interfaces.CacheType, remoteInstanceName string) (interfaces.Cache, error)
- func (c *DiskCache) Writer(ctx context.Context, d *repb.Digest) (io.WriteCloser, error)
- type MapEntry
- type MemoryCache
- func (m *MemoryCache) Check(ctx context.Context) error
- func (m *MemoryCache) Contains(ctx context.Context, d *repb.Digest) (bool, error)
- func (m *MemoryCache) Delete(ctx context.Context, d *repb.Digest) error
- func (m *MemoryCache) FindMissing(ctx context.Context, digests []*repb.Digest) ([]*repb.Digest, error)
- func (m *MemoryCache) Get(ctx context.Context, d *repb.Digest) ([]byte, error)
- func (m *MemoryCache) GetMulti(ctx context.Context, digests []*repb.Digest) (map[*repb.Digest][]byte, error)
- func (m *MemoryCache) Reader(ctx context.Context, d *repb.Digest, offset int64) (io.ReadCloser, error)
- func (m *MemoryCache) Set(ctx context.Context, d *repb.Digest, data []byte) error
- func (m *MemoryCache) SetMulti(ctx context.Context, kvs map[*repb.Digest][]byte) error
- func (m *MemoryCache) Size() int64
- func (m *MemoryCache) WithIsolation(ctx context.Context, cacheType interfaces.CacheType, remoteInstanceName string) (interfaces.Cache, error)
- func (m *MemoryCache) Writer(ctx context.Context, d *repb.Digest) (io.WriteCloser, error)
- type Metrics
- type MultiCloser
- type ReadCloser
- type RedisCache
- func (r *RedisCache) Check(ctx context.Context) error
- func (r *RedisCache) Contains(ctx context.Context, d *repb.Digest) (bool, error)
- func (r *RedisCache) Delete(ctx context.Context, d *repb.Digest) error
- func (r *RedisCache) FindMissing(ctx context.Context, digests []*repb.Digest) ([]*repb.Digest, error)
- func (r *RedisCache) Get(ctx context.Context, d *repb.Digest) ([]byte, error)
- func (r *RedisCache) GetMulti(ctx context.Context, digests []*repb.Digest) (map[*repb.Digest][]byte, error)
- func (r *RedisCache) Reader(ctx context.Context, d *repb.Digest, offset int64) (io.ReadCloser, error)
- func (r *RedisCache) Set(ctx context.Context, d *repb.Digest, data []byte) error
- func (r *RedisCache) SetMulti(ctx context.Context, kvs map[*repb.Digest][]byte) error
- func (r *RedisCache) Size() int64
- func (r *RedisCache) WithIsolation(ctx context.Context, cacheType interfaces.CacheType, remoteInstanceName string) (interfaces.Cache, error)
- func (r *RedisCache) Writer(ctx context.Context, d *repb.Digest) (io.WriteCloser, error)
Constants ¶
View Source
const ( // HashPrefixDirPrefixLen is length heads hash prefix // get the first 4 character of hash string, then save // the content to rootDir/hash{0:4}/hash HashPrefixDirPrefixLen = 4 )
Variables ¶
This section is empty.
Functions ¶
func GenerateCacheFromConfig ¶
func GenerateCacheFromConfig(cacheCfg *config.CacheConfig) interfaces.Cache
func NewComposedCache ¶
func NewComposedCache(inner, outer interfaces.Cache, mode CacheMode) interfaces.Cache
func NewDiskCache ¶
func NewDiskCache(cfg *config.Cache) interfaces.Cache
func NewMemoryCache ¶
func NewMemoryCache(cfg *config.Cache) interfaces.Cache
func NewRedisCache ¶
func NewRedisCache(cfg *config.Cache) interfaces.Cache
Types ¶
type CacheMode ¶
type CacheMode uint32
const ( // ModeReadThrough means that if we Get a key from ComposedCache and not found in outer(faster) one, // then we will get from inner(slower) one, and set the result into outer. ModeReadThrough CacheMode = 1 << (iota + 1) // ModeWriteThrough means that if we 'Set' a key into ComposedCache, it will be not only 'Set' into inner(slower) one, // and also be 'Set' into outer(faster) one. ModeWriteThrough )
type ComposedCache ¶
type ComposedCache struct {
// contains filtered or unexported fields
}
ComposedCache hold two caches and take the outer one as a faster one take inner one as slower one.
- When invoking Get, first get from outer(faster) one, if not found in outer(faster) one, then it will find in inner(slower) one.
- If it found in outer(faster) one && ModeReadThrough was set, the result from outer(faster) one will be Set into inner(slower) one.
- If we set a pair of key and value, this key will be set into inner(slower) one first, and then if ModeWriteThrough was set, this key will be set in outer(faster) one.
func (*ComposedCache) FindMissing ¶
func (*ComposedCache) Reader ¶
func (c *ComposedCache) Reader(ctx context.Context, d *repb.Digest, offset int64) (io.ReadCloser, error)
func (*ComposedCache) Size ¶
func (c *ComposedCache) Size() int64
Size get the inner size + outer size
func (*ComposedCache) WithIsolation ¶
func (c *ComposedCache) WithIsolation(ctx context.Context, cacheType interfaces.CacheType, remoteInstanceName string) (interfaces.Cache, error)
func (*ComposedCache) Writer ¶
func (c *ComposedCache) Writer(ctx context.Context, d *repb.Digest) (io.WriteCloser, error)
type DiskCache ¶
type DiskCache struct {
// contains filtered or unexported fields
}
DiskCache implements the disk-based interfaces.Cache
func (*DiskCache) FindMissing ¶
func (*DiskCache) WithIsolation ¶
func (c *DiskCache) WithIsolation(ctx context.Context, cacheType interfaces.CacheType, remoteInstanceName string) (interfaces.Cache, error)
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
func (*MemoryCache) FindMissing ¶
func (*MemoryCache) Reader ¶
func (m *MemoryCache) Reader(ctx context.Context, d *repb.Digest, offset int64) (io.ReadCloser, error)
func (*MemoryCache) Size ¶
func (m *MemoryCache) Size() int64
func (*MemoryCache) WithIsolation ¶
func (m *MemoryCache) WithIsolation(ctx context.Context, cacheType interfaces.CacheType, remoteInstanceName string) (interfaces.Cache, error)
func (*MemoryCache) Writer ¶
func (m *MemoryCache) Writer(ctx context.Context, d *repb.Digest) (io.WriteCloser, error)
type Metrics ¶
func (*Metrics) GetHitRate ¶
type MultiCloser ¶
type MultiCloser struct {
// contains filtered or unexported fields
}
func (*MultiCloser) Close ¶
func (m *MultiCloser) Close() error
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
func (*RedisCache) FindMissing ¶
func (*RedisCache) Reader ¶
func (r *RedisCache) Reader(ctx context.Context, d *repb.Digest, offset int64) (io.ReadCloser, error)
func (*RedisCache) Size ¶
func (r *RedisCache) Size() int64
func (*RedisCache) WithIsolation ¶
func (r *RedisCache) WithIsolation(ctx context.Context, cacheType interfaces.CacheType, remoteInstanceName string) (interfaces.Cache, error)
func (*RedisCache) Writer ¶
func (r *RedisCache) Writer(ctx context.Context, d *repb.Digest) (io.WriteCloser, error)
Click to show internal directories.
Click to hide internal directories.