ttl

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package ttl provides a synchronised map that auto-expire

This package is simply to provide a storage for session.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Cache is a synchronised map of items that auto-expire once stale

func NewCache

func NewCache(ttl time.Duration) *Cache

NewCache 创建指定生命周期的 Cache

func (*Cache) Delete

func (c *Cache) Delete(key interface{})

Delete 删除指定key

func (*Cache) Get

func (c *Cache) Get(key interface{}) interface{}

Get 通过 key 获取指定的元素

func (*Cache) Set

func (c *Cache) Set(key interface{}, val interface{})

Set 设置指定 key 的值

func (*Cache) Touch

func (c *Cache) Touch(key interface{}, ttl time.Duration)

Touch 为指定key添加一定生命周期

type Item

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

Item represents a record in the cache map

Jump to

Keyboard shortcuts

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