Documentation ¶
Index ¶
- func New(opt *Option) (fscache.Cache, error)
- func NewSCache(opt *Option) (fscache.SCache, error)
- type Option
- type SCache
- func (L *SCache) Delete(ctx context.Context, key any) fscache.DeleteResult
- func (L *SCache) Get(ctx context.Context, key any) fscache.GetResult
- func (L *SCache) Has(ctx context.Context, key any) fscache.HasResult
- func (L *SCache) Reset(ctx context.Context) error
- func (L *SCache) Set(ctx context.Context, key any, val any, ttl time.Duration) fscache.SetResult
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New 创建新的 lru 缓存实例
参数 opt:必填
Example ¶
package main import ( "context" "fmt" "time" "github.com/fsgo/fscache/lrucache" ) func main() { cache, err := lrucache.New(&lrucache.Option{Capacity: 1000}) fmt.Println("err_is_nil=", err == nil) ret := cache.Set(context.Background(), "k1", "v1", time.Second) fmt.Println("set_success=", ret.Err == nil) }
Output: err_is_nil= true set_success= true
Types ¶
Click to show internal directories.
Click to hide internal directories.