Skip to content

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.

Notifications You must be signed in to change notification settings

mohammadhasanii/Golang-Redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages