| id | index-usinggo | |
|---|---|---|
| title | How to cache JSON data in Redis with Go | |
| sidebar_label | RedisJSON and Go | |
| slug | /howtos/redisjson/using-go | |
| authors |
|
import Authors from '@theme/Authors';
Go-ReJSON is a Go client for RedisJSON Module. It is a Golang client that support multiple Redis clients such as the print-like Redis-api client redigo and the type-safe Redis client go-redis.
Follow the below steps to get started with RedisJSON using Go client.
go mod init github.com/my/repo go get github.com/go-redis/redis/v8 go get github.com/nitishm/go-rejson/v4 git clone https://github.com/nitishm/go-rejson
cd go-rejson/exampleCommand:
go build json_set/json_set.goResult:
go: downloading github.com/go-redis/redis/v8 v8.4.4
go: downloading github.com/gomodule/redigo v1.8.3
go: downloading go.opentelemetry.io/otel v0.15.0
go build: build output "json_set" already exists and is a directoryCommand:
go run json_set/json_set.goResult:
Executing Example_JSONSET for Redigo Client
Success: OK
Student read from redis : main.Student{Name:main.Name{First:"Mark", Middle:"S", Last:"Pronto"}, Rank:1}
Executing Example_JSONSET for Redigo Client
Success: OK
Student read from redis : main.Student{Name:main.Name{First:"Mark", Middle:"S", Last:"Pronto"}, Rank:1}Command:
pwd
go-rejson/examplesCommand:
go run json_array/json_array.goResult:
Executing Example_JSONSET for Redigo Client
arr: OK
arr before pop: [one two three four five]
Length: 5
Deleted element: five
arr after pop: [one two three four]
Length: 4
Index of "one": 0
Out of range: -1
"ten" not found: -1
no. of elements left: 2
arr after trimming to [1,2]: [two three]
no. of elements: 3
arr after inserting "one": [one two three]
Executing Example_JSONSET for Redigo Client
arr: OK
arr before pop: [one two three four five]
Length: 5
Deleted element: five
arr after pop: [one two three four]
Length: 4
Index of "one": 0
Out of range: -1
"ten" not found: -1
no. of elements left: 2
arr after trimming to [1,2]: [two three]
no. of elements: 3
arr after inserting "one": [one two three]- Go and Redis
- RU204: Storing, Querying and Indexing JSON at Speed - a course at Redis University
- RedisJSON and Python
- How to store and retrieve nested JSON document
- Importing JSON data into Redis using NodeJS
- Learn more about RedisJSON in the Quickstart tutorial.
- How to build shopping cart app using NodeJS and RedisJSON
- Indexing, Querying, and Full-Text Search of JSON Documents with Redis