go_filecache

package module
v0.0.2-0...-260de49 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: MIT Imports: 8 Imported by: 0

README

使用方法

package main

import (
	"fmt"
	gofilecache "github.com/mimicode/go-filecache"
)

func main() {
	cache := gofilecache.Default()
	cache.Set("xiaoming", "xiaoming", 300)
	val := cache.Get("xiaoming")
	fmt.Println(string(val))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileCache

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

func Default

func Default() *FileCache

func New

func New(config FileCacheConfig) *FileCache

func (*FileCache) Del

func (fc *FileCache) Del(key string)

删除缓存

func (*FileCache) Exists

func (fc *FileCache) Exists(key string) bool

判断key是否存在

func (*FileCache) Get

func (fc *FileCache) Get(key string) []byte

func (*FileCache) Set

func (fc *FileCache) Set(key, value string, exp int64) bool

设置缓存

type FileCacheConfig

type FileCacheConfig struct {
	//缓存文件目录级别
	PathLevel int
	//缓存目录
	CachePath string
	//缓存文件后缀
	CacheFileSuffix string

	//gc 概率 百万分只1  0 - 1000000
	GcProbability int
	//目录权限
	DirMode os.FileMode
	// contains filtered or unexported fields
}

配置

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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