redis-client

module
v0.0.0-...-45586d8 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT

README

redis client for go

redis client library is to make easy to do crud with json object in redis

Features

  • create json objects
  • update json objects
  • delete json object
  • add list
  • edit list
  • remove list items by key
  • delete list by key

Installing the Library

go get https://github.com/jason-shen/redis-client

Usage

example of Create/Update

func main()  {
redis := client.NewRedisCache("localhost:6379", "", 1, 1000)
key := "myfirst_key"
sample := map[string]interface{} {
"firstname": "hello1",
"lastname": "world0",
}

sample2 := map[string]interface{} {
"firstname": "hello2",
"lastname": "world1",
}
sample3 := map[string]interface{} {
"firstname": "hello3",
"lastname": "world2",
}

redis.Create(key, sample)
data, err := redis.Read(key)
if err != nil {
panic(err)
}
fmt.Println("object create", data)
redis.Update(key, sample2)
data2, err := redis.Read(key)
fmt.Println("object update 1", data2)
redis.Update(key, sample3)
data3, err := redis.Read(key)
fmt.Println("object update 2", data3)
}

result

image for the full code please see the example folder

Dependencies

License

MIT License - see LICENSE for full text

Directories

Path Synopsis
examples
pkg

Jump to

Keyboard shortcuts

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