cache

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Items map[string]*Item `json:"items" msg:"items"`
}

func (*Bucket) DecodeMsg

func (z *Bucket) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Bucket) EncodeMsg

func (z *Bucket) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Bucket) MarshalMsg

func (z *Bucket) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Bucket) Msgsize

func (z *Bucket) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Bucket) UnmarshalMsg

func (z *Bucket) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Cache

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

func New

func New(localDir string, flushInterval time.Duration) *Cache

func (*Cache) Delete

func (c *Cache) Delete(keys ...string)

func (*Cache) Get

func (c *Cache) Get(key string, timeoutSecond int64, handler func() ([]byte, error)) []byte

func (*Cache) GetValue

func (c *Cache) GetValue(key string, timeoutSecond int64) (value []byte, exists bool)

func (*Cache) Info

func (c *Cache) Info() Info

func (*Cache) Length

func (c *Cache) Length() int64

func (*Cache) SetValue

func (c *Cache) SetValue(key string, value []byte)

func (*Cache) SyncLocal

func (c *Cache) SyncLocal()

type Info

type Info struct {
	LocalDir       string `json:"localDir"`
	FlushInterval  string `json:"flushInterval"`
	Length         int64  `json:"length"`
	LatestSyncTime string `json:"latestSyncTime"`
	Items          []Item `json:"items"`
}

type Item

type Item struct {
	Key         string `json:"key" msg:"-"`
	Value       []byte `json:"value" msg:"value"`
	Hit         int64  `json:"hit" msg:"-"`
	Miss        int64  `json:"miss" msg:"-"`
	InvokeCount int64  `json:"invokeCount" msg:"-"`
	CreatedAt   int64  `json:"createdAt" msg:"createdAt"`
	// contains filtered or unexported fields
}

func (*Item) DecodeMsg

func (z *Item) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Item) EncodeMsg

func (z *Item) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Item) MarshalMsg

func (z *Item) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Item) Msgsize

func (z *Item) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Item) UnmarshalMsg

func (z *Item) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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