cache

package
v0.0.64 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BenchmarkCacheStruct

func BenchmarkCacheStruct(b *testing.B)

func Init

func Init() (err error)

Types

type Cache

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

func New

func New(model any) *Cache

New creates a globalCache object. mode could be a pointer or not pointer. eg: New(&service{}) or New(service{})

more usage see test case.

func (*Cache) Cap

func (c *Cache) Cap() int

func (*Cache) Close

func (c *Cache) Close() (err error)

func (*Cache) Delete

func (c *Cache) Delete(key string) error

func (*Cache) Get

func (c *Cache) Get(key string) (any, error)

Get get entry from cache. NOTE: Get always returns pointer and always not nil, eg: &service{}, new(string). more detail see test cases.

func (*Cache) Len

func (c *Cache) Len() int

func (*Cache) Reset

func (c *Cache) Reset() error

func (*Cache) Set

func (c *Cache) Set(key string, entry any) error

Set add entry to cache. entry could be struct or pointer, eg: Set(key, &Service) or Set(key, Service{}). more detail se test cases.

type SessionStore

type SessionStore Cache

func NewSessionStore

func NewSessionStore(model any) *SessionStore

NewSessionStore creates a session store that expires automatically.

func (*SessionStore) Cap

func (c *SessionStore) Cap() int

func (*SessionStore) Close

func (c *SessionStore) Close() (err error)

func (*SessionStore) Delete

func (c *SessionStore) Delete(key string) error

func (*SessionStore) Get

func (c *SessionStore) Get(key string) (any, error)

func (*SessionStore) Len

func (c *SessionStore) Len() int

func (*SessionStore) Reset

func (c *SessionStore) Reset() error

func (*SessionStore) Set

func (c *SessionStore) Set(key string, entry any) error

Jump to

Keyboard shortcuts

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