Giter Site home page Giter Site logo

redisgo's Introduction

redisgo

基于github.com/gomodule/redigo,对常用的redis用法进行了封装,让你更方便的使用。

特性

  • 支持连接池
  • 支持退出时关闭连接池
  • 支持各种类型数据的存储和读取,可以直接获取指定类型的存储值
  • 支持有序集合,可以用来做延迟队列或排行榜等用途
  • 支持redis订阅/发布,在redis故障或网络异常时,自动重新订阅
  • 支持列表,包含阻塞式和非阻塞式读取

安装

go get -u github.com/aiscrm/cache

快速开始

package main

import (
	"fmt"

	"github.com/aiscrm/redisgo"
)

type User struct {
	Name string
	Age  int
}

func main() {
	c, err := redisgo.New(
		redisgo.Options{
			Addr:     "127.0.0.1:6379",
			Password: "",
			Prefix:   "aiscrm_",
		})
	if err != nil {
		panic(err)
	}
	c.Set("name", "corel", 30)
	c.Set("age", "23", 30)
	name, err := c.GetString("name")
	age, err := c.GetInt("age")
	fmt.Printf("Name=%s, age=%d", name, age)
	user := &User{
		Name: "corel",
		Age:  23,
	}
	c.Set("user", user, 30)
	user2 := &User{}
	c.GetObject("user", user2)
	fmt.Printf("user: %+v", user2)
}

特别鸣谢

redisgo's People

Contributors

aiscrm avatar

Watchers

James Cloos 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.