clash

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NeverExpired = time.Time{}

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Stats() Stats
	Del(key string)
	SetExpired(key string, value []byte, expiredAt time.Time)
	GetExpired(key string) (value []byte, expiredAt time.Time, found bool)

	Range(func(key string, value []byte, expiredAt time.Time) bool)
}

type CacheNode

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

func New

func New(log logrus.FieldLogger, cache Cache, swarm Swarm, storage Storage, ops ...Option) (node *CacheNode)

func (*CacheNode) Del

func (node *CacheNode) Del(ctx context.Context, key string)

func (*CacheNode) Get

func (node *CacheNode) Get(ctx context.Context, key string) (value []byte, expiredAt time.Time, found bool)

func (*CacheNode) Owners added in v0.7.0

func (node *CacheNode) Owners(key string) (owners []string)

func (*CacheNode) Rebase

func (node *CacheNode) Rebase(ctx context.Context)

func (*CacheNode) Set

func (node *CacheNode) Set(ctx context.Context, key string, value []byte)

func (*CacheNode) SetExpired

func (node *CacheNode) SetExpired(ctx context.Context, key string, value []byte, expiredAt time.Time)

func (*CacheNode) SetTTL

func (node *CacheNode) SetTTL(ctx context.Context, key string, value []byte, ttlSeconds int)

func (*CacheNode) Stats

func (node *CacheNode) Stats(_ context.Context) (stats Stats)

type Node

type Node interface {
	ID() string
	GetTransport() Transport
}

type Option

type Option func(cache *CacheNode)

type Stats

type Stats struct {
	Hit   uint64 `json:"hit"`
	Miss  uint64 `json:"miss"`
	Bytes uint64 `json:"bytes"`
	Items uint64 `json:"items"`
}

type Storage

type Storage interface {
	Load(ctx context.Context, key string) (value []byte, expiredAt time.Time, err error)
}

type Swarm

type Swarm interface {
	Name() string
	KeyOwners(key string) []Node
	OnRebase(func(ctx context.Context))

	Del(ctx context.Context, key string) (err error)
	Set(ctx context.Context, key string, value []byte, expiredAt time.Time) (err error)

	OnStats(func(ctx context.Context) Stats)
	OnDel(func(ctx context.Context, key string))
	OnSet(func(ctx context.Context, key string, value []byte, expiredAt time.Time))
	OnGet(func(ctx context.Context, key string) (value []byte, expiredAt time.Time, found bool))
}

type Transport

type Transport interface {
	Get(ctx context.Context, key string) (value []byte, expiredAt time.Time, err error)
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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