Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/onskycloud/go-redis

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/onskycloud/go-redis

  • v1.0.2
  • Source
  • Go
  • Socket score

Version published
Created
Source

Go-redis Helper

N|Solid

Build Status

Redis client for golang

Getting Started!

Get by key

func (r *Redis) Get(key string) (string, error) {
  return r.db.Get(key).Result()
}

Get by key and field

func (r *Redis) GetObject(objectKey string, field string, result interface{}) error {
  temp, err := r.db.HGet(objectKey, field).Bytes()
  if err != nil {
    return err
  }
  err = msgpack.Unmarshal(temp, result)
  return err
}

Set by key

func (r *Redis) Set(key string, value interface{}, expiration time.Duration) (string, error) {
  return r.db.Set(key, value, expiration).Result()
}

Set by key and field

func (r *Redis) SetObject(objectKey string, field string, value interface{}) (bool, error) {
  bytes, err := msgpack.Marshal(value)
  if err != nil {
  	return false, err
  }
  return r.db.HSet(objectKey, field, bytes).Result()
}

Check exist by key and field

// CheckExistedObject will return true if the object is existed.
func (r *Redis) CheckExistedObject(objectKey string, field string) (bool, error) {
  existed, err := r.db.HExists(objectKey, field).Result()
  if err != nil {
    return false, err
  }
  if existed == true {
    return true, nil
  }
  return false, nil
}

Installation

Request handler requires Go v1.13+ to run.

Install the package.

$ go get -u github.com/onskycloud/go-redis
Kubernetes + Google Cloud

See KUBERNETES.md

Todos

  • Write MORE Tests
  • Add Night Mode

License

MIT

FAQs

Package last updated on 21 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc