/Golang-Redis

This source, using Golang and Redis, gives you the power to set your data on Redis or call them without using your main database, and it makes you faster and does not put pressure on the database.

Primary LanguageGo

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