Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 882 Bytes

README.md

File metadata and controls

55 lines (36 loc) · 882 Bytes

Golang-Redis

This package was developed for redis by the Go language

Logo

Usage/Examples

package main

import (
	"context"
	"fmt"
	"github.com/redis/go-redis/v9"
)

func main() {
	context := context.Background()
	rdb := redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "", // no password set
		DB:       0,  // use default DB
	})
	keyName := "lastname"
	value := "Ahamadi"
	err := rdb.Set(context, keyName, value, 0).Err()
	if err != nil {
		panic(err)
	}

	val, err := rdb.Get(context, keyName).Result()
	if err != nil {
		panic(err)
	}
	fmt.Println(keyName, val)

}

Run Application

Install golang and redis on port 6379

  go run app.go