Skip to content

simple tool for interacting with redis databases | also redis databases with SSL

License

Notifications You must be signed in to change notification settings

gopy-art/zrediss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub go.mod Go version of a Go module GitHub go.mod Go version of a Go module Go Reference

zrediss

simple tool for interacting with redis databases and redis databases with SSL

Quick Start

first you have to download the package with this command :

go get github.com/gopy-art/zrediss

then you can use this package in your code, here is an example of using this package:

package example

import (
	"fmt"
	"log"
	"os"

	"github.com/gopy-art/zrediss/connection"
)

/*
This function connect to the redis database and get all the keys for more actions
*/
func ConnectAndGetAllKeys() {
	redisHandler := connection.RedisConnection{
		RedisAddress: "redis://localhost:6379",
	}
	err := redisHandler.InitConnection()
	if err != nil {
		log.Fatalf("error in connect to redis, error = %v", err)
	}

	results, err := redisHandler.GetAllKeys()
	if err != nil {
		log.Fatalf("error in get all keys, error = %v", err)
	}

	if len(results) == 0 {
		log.Println("redis database is empty")
		os.Exit(0)
	}

	for n, key := range results {
		fmt.Printf("%v ) %v \n", n, key)
	}
}

Start With Module

first you have to download the project or clone it from the github.

then go to the root directory of the project and run this command :

go build

now you cna use this module in your server !

get all the keys :

./zrediss -u redis://localhost:6379 -action all

get one key with value :

./zrediss -u redis://localhost:6379 -action get -k key1

set one key with value :

./zrediss -u redis://localhost:6379 -action set -k key1 -s value1

delete all keys from redis :

./zrediss -u redis://localhost:6379 -action flush

delete just one key :

./zrediss -u redis://localhost:6379 -action delete -k key1

falgs

  -action string
        set the action of the module. (all, get, set, delete, flush)
  -k string
        set rediss key to get the value
  -l string
        set app logger type , stdout or file (default "stdout")
  -s string
        set value for the specific key
  -u string
        set rediss url
  -v    zrediss version
  -val string
        set rediss value for set the value

About

simple tool for interacting with redis databases | also redis databases with SSL

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages