saCache

package
v0.0.0-...-b2602dc Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

README

本地缓存处理

saCache
内存缓存
  1. 最多500条,超出会删除最早的数据,一次性删除40%数据

  2. 防止并发更新:调用handler前必须抢到锁,并且更新时间超过1秒

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MGet

func MGet(key string) (value interface{}, expired bool)

func MSetWithFunc

func MSetWithFunc(key string, duration time.Duration, handler CacheHandle) (value interface{}, expired bool)

MSetWithFunc 最多500条,超出会删除最早的数据,一次性删除三分之一 防止并发更新:调用handler前必须抢到锁,并且更新时间超过1秒

Types

type Cache

type Cache struct {
	Before   time.Time //有效期
	Data     interface{}
	UpdateAt time.Time //更新时间1秒内也不会更新
	// contains filtered or unexported fields
}

type CacheHandle

type CacheHandle func() (interface{}, error)

Jump to

Keyboard shortcuts

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