cached

package
v0.0.0-...-a14a4d2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Resource type definitions
	// ResourceTypeArtifact defines artifact type.
	ResourceTypeArtifact = "artifact"
	// ResourceTypeProject defines project type.
	ResourceTypeProject = "project"
	// ResourceTypeProject defines project metadata type.
	ResourceTypeProjectMeta = "project_metadata"
	// ResourceTypeRepository defines repository type.
	ResourceTypeRepository = "repository"
	// ResourceTypeManifest defines manifest type.
	ResourceTypeManifest = "manifest"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseManager

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

BaseManager is the base manager for cache and implement the cache manager interface.

func NewBaseManager

func NewBaseManager(resourceType string) *BaseManager

NewBaseManager returns a instance of base manager.

func (*BaseManager) CacheClient

func (bm *BaseManager) CacheClient(_ context.Context) cache.Cache

CacheClient returns the cache client.

func (*BaseManager) CountCache

func (bm *BaseManager) CountCache(ctx context.Context) (int64, error)

CountCache returns current this resource occupied cache count.

func (*BaseManager) DeleteCache

func (bm *BaseManager) DeleteCache(ctx context.Context, key string) error

DeleteCache deletes specific cache by key.

func (*BaseManager) FlushAll

func (bm *BaseManager) FlushAll(ctx context.Context) error

FlushAll flush this resource's all cache.

func (*BaseManager) ResourceType

func (bm *BaseManager) ResourceType(_ context.Context) string

ResourceType returns the resource type.

func (*BaseManager) WithCacheClient

func (bm *BaseManager) WithCacheClient(cc cache.Cache) *BaseManager

WithCacheClient can override the default cache client.

type Manager

type Manager interface {
	// CacheClient returns the cache client.
	CacheClient(ctx context.Context) cache.Cache
	//  ResourceType returns the resource type.
	//  eg. artifact、project、tag、repository
	ResourceType(ctx context.Context) string
	// CountCache returns current this resource occupied cache count.
	CountCache(ctx context.Context) (int64, error)
	// DeleteCache deletes specific cache by key.
	DeleteCache(ctx context.Context, key string) error
	// FlushAll flush this resource's all cache.
	FlushAll(ctx context.Context) error
}

Manager is the interface for resource cache manager. Provides common interfaces for admin to view and manage resource cache.

type ObjectKey

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

ObjectKey normalizes cache object key.

func NewObjectKey

func NewObjectKey(ns string) *ObjectKey

NewObjectKey returns object key with namespace.

func (*ObjectKey) Format

func (ok *ObjectKey) Format(keysAndValues ...interface{}) (string, error)

Format formats fields to string. eg. namespace: 'artifact' Format("id", 100, "digest", "aaa"): "artifact:id:100:digest:aaa"

Directories

Path Synopsis
artifact
manifest
project
project_metadata
repository

Jump to

Keyboard shortcuts

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