Categorygithub.com/rehok/go-cache
modulepackage
0.0.7
Repository: https://github.com/rehok/go-cache.git
Documentation: pkg.go.dev

# README

go-cache

Generic cache use and cache manager for golang. Provide a unified usage API by packaging various commonly used drivers.

Install

go get github.com/fasthey/go-cache

Cache Interface

Usage

package main

import (
	"fmt"

	"github.com/fasthey/go-cache"
)

func main() {

	// redis
	// newCache, err := cache.New(cache.Options{
	// 	Adapter:       "redis",
	// 	AdapterConfig: "addr=xxxx,password=xxxx,db=db1,prefix=fasthey",
	// 	OccupyMode:    true,
	// })
	// if err == nil {
	// 	fmt.Printf("error is :%v", err)
	// }

	// file

	newCache, err := cache.New(cache.Options{
		Adapter:       "file",
		AdapterConfig: "cache",
		OccupyMode:    true,
	})
	if err != nil {
		fmt.Printf("error is :%v", err)
	}
	err = newCache.Set("key", "is test", 0)
	if err != nil {
		fmt.Printf("set error is :%v", err)
	}
	data, err := newCache.Get("key")
	if err != nil {
		fmt.Printf("get error is :%v", err)
	}
	fmt.Println(data)
}

# Packages

No description provided by the author

# Functions

* * @desc: 字节转字符串 * @return {*} */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
* * @desc: 解析grom的表名 * @param {string} str * @return {*} */.
* * @desc: 排除掉多余的字段 * @param {string} str * @return {*} */.
No description provided by the author
No description provided by the author
Cacher is a middleware that maps a cache.Cache service into the Macaron handler chain.
NewCacher creates and returns a new cacher by given adapter name and configuration.
NewFileCache creates and returns a new file cacher.
Register registers a adapter.
No description provided by the author
* * @desc: 字符串转字节 * @return {*} */.
No description provided by the author

# Structs

FileCache represents a file cache adapter implementation.
Item represents a cache item.
Options represents a struct for specifying configuration options for the cache middleware.
RedisCache represents a redis cache adapter implementation.

# Interfaces

Cache is the interface that operates the cache data.