cache

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache() *Cache

func (*Cache) Get

func (c *Cache) Get(k string) (v interface{})

func (*Cache) Set

func (c *Cache) Set(k string, v interface{})

type Config

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

func Configure

func Configure() *Config

func (*Config) MaxSize

func (c *Config) MaxSize() int64

func (*Config) TTL

func (c *Config) TTL() time.Duration

func (*Config) WithMaxSize

func (c *Config) WithMaxSize(s int64) *Config

func (*Config) WithTTL

func (c *Config) WithTTL(ttl time.Duration) *Config

type Filter

type Filter interface {
	Name(ctx context.Context, parent *Node) string
	Init(ctx context.Context, parent *Node) (*Node, error)
}

type Node

type Node struct {
	// user data
	Cache *Cache
	// tree will set the value below after the node added in.
	Name   string
	Tree   *Tree
	Childs *util.ConcurrentMap
	Level  int
}

func NewNode

func NewNode() *Node

func (*Node) ChildNodes

func (n *Node) ChildNodes() (nodes []*Node)

type Option

type Option struct {
	Level   int
	NoCache bool
}

func Options

func Options() (op Option)

func (Option) Temporary

func (op Option) Temporary(b bool) Option

get node without cache

func (Option) ToLevel

func (op Option) ToLevel(l int) Option

get node before level l

type Tree

type Tree struct {
	Config *Config
	// contains filtered or unexported fields
}

func NewTree

func NewTree(cfg *Config) *Tree

func (*Tree) AddFilter

func (t *Tree) AddFilter(fs ...Filter) *Tree

func (*Tree) Get

func (t *Tree) Get(ctx context.Context, ops ...Option) (node *Node, err error)

func (*Tree) Remove

func (t *Tree) Remove(ctx context.Context)

Jump to

Keyboard shortcuts

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