local

package
v0.0.0-...-3d0adf2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : local.go # Created : 2019/1/15 16:48 # Last Modified : 2019/1/15 16:48 # Describe : # # ====================================================

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client 本地缓存的客户端

func NewClient

func NewClient() *Client

NewClient 新建一个本地缓存,默认每个key的过期时间5分钟,默认10分钟刷新一次

func (*Client) Add

func (c *Client) Add(ctx context.Context, k string, v []byte, ttl int64) error

Add 如果key不存在就将key和value保存,如果key存在就返回错误

func (*Client) Append

func (c *Client) Append(ctx context.Context, k string, v []byte) error

Append 本地缓存不实现append Deprecated: don't use this method.

func (*Client) Close

func (c *Client) Close() error

Close 关闭缓存,本地缓存无需关闭,直接返回nil

func (*Client) Del

func (c *Client) Del(ctx context.Context, k string) error

Del 按照key删除value

func (*Client) Get

func (c *Client) Get(ctx context.Context, s string) ([]byte, error)

Get 按照key获取value , 如果不存在则返回ErrCacheMiss

func (*Client) IsMember

func (c *Client) IsMember(ctx context.Context, k string, v []byte) (bool, error)

IsMember 本地缓存不实现IsMember Deprecated: don't use this method.

func (*Client) Put

func (c *Client) Put(ctx context.Context, k string, v []byte, ttl int64) error

Put 将v存入本地缓存,ttl为缓存的有效时间,单位(s)

Jump to

Keyboard shortcuts

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