Giter VIP home page Giter VIP logo

cache's Introduction

cache

使用方法:

//首先取一个cache的struct

//可以利用不同的patch进行批量删除

key:="luyu6056"

patch:="member_info"

cache := libraries.Hget(key,patch)

//读取一个缓存数据

last_login_time := cache.Load("login_time")

//储存一个临时缓存,重启进程失效,不会进行持久化写入

//cache.Stroe(key interface{},value interface{})

cache.Stroe("login_time",libraries.Timestamp())

//传入一个持久化数据,写入硬盘

member_info:=map[string]interface{}{"age":18,"sex":"man","birthday":"1970-01-01"}

//Hset方法,默认每秒钟写入一次硬盘

libraries.Hset(key,member_info,patch,0)

//Hset_r方法,立即写入硬盘

libraries.Hset_r(key,member_info,patch,86400)//整个缓存有效时间86400,超时该key清空所有数据

//删除一条key

libraries.Hdel(key,patch)

//删除整个patch

libraries.Hdel_all(patch)

队列

以redis的list为参照集成了RPUSH、LPUSH、LPOP、RPOP、LINDEX、LLEN、LRANGE、LREM、LTRIM,例子在cache.go尾部

cache's People

Contributors

luyu6056 avatar

Stargazers

app avatar

Watchers

James Cloos avatar app avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.