Categorygithub.com/altipla-consulting/redis
repositorypackage
1.11.2
Repository: https://github.com/altipla-consulting/redis.git
Documentation: pkg.go.dev

# README

redis

GoDoc Build Status

Abstraction layer to access Redis with repositories and models.

Install

go get github.com/altipla-consulting/redis

Usage

Repository file:

package models

import (
  "fmt"

  "github.com/altipla-consulting/redis"
)

var Repo *MainDatabase

func ConnectRepo() error {
  Repo = &MainDatabase{
    sess: redis.Open("redis:6379", "cells"),
  }

  return nil
}

type MainDatabase struct {
  sess *redis.Database
}

func (repo *MainDatabase) Offers(hotel int64) *redis.ProtoHash {
  return repo.sess.ProtoHash(fmt.Sprintf("hotel:%d", hotel))
}

func (repo *MainDatabase) CloseOffers() *redis.Queue {
  return repo.sess.Queue("close-offers")
}

Usage:

func run() error {
  offers := []*pbmodels.Offer{}
  if err := models.Repo.Offers(in.Hotel).GetMulti(codes, &offers); err != nil {
    return err
  }
}

Contributing

You can make pull requests or create issues in GitHub. Any code you send should be formatted using gofmt.

Running tests

Run the tests

make test

License

MIT License