astiredis

package module
v0.0.0-...-0228293 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2018 License: MIT Imports: 9 Imported by: 0

README

Astiredis

Wrapper on top of redis to provide proper configuration

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Addr   = flag.String("redis-addr", "", "the redis addr")
	Prefix = flag.String("redis-prefix", "", "the redis prefix")
)

Flags

View Source
var Nil = redis.Nil

Nil error

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a client

func New

func New(c Configuration) *Client

New returns a client based on a configuration

func (*Client) Del

func (c *Client) Del(k string) error

Del deletes a key

func (*Client) Get

func (c *Client) Get(k string, v interface{}) error

Get gets a value

func (*Client) NewMutex

func (c *Client) NewMutex(ctx context.Context) *Mutex

NewMutex creates a new mutex

func (*Client) NewMutexWithOptions

func (c *Client) NewMutexWithOptions(ctx context.Context, o MutexOptions) *Mutex

NewMutexWithOptions creates a new mutex with options

func (*Client) Set

func (c *Client) Set(k string, v interface{}, ttl time.Duration) error

Set sets a value

func (*Client) SetNX

func (c *Client) SetNX(k string, v interface{}, ttl time.Duration) (bool, error)

SetNX sets a value if it doesn't exist

type Configuration

type Configuration struct {
	Addr   string `toml:"addr"`
	Prefix string `toml:"prefix"`
}

Configuration represents the configuration of the proxy

func FlagConfig

func FlagConfig() Configuration

FlagConfig generates a Configuration based on flags

type Mutex

type Mutex struct {
	// contains filtered or unexported fields
}

Mutex represents a distributed mutex

func (*Mutex) Lock

func (l *Mutex) Lock() (err error)

Lock lock the mutex

func (*Mutex) Unlock

func (l *Mutex) Unlock() (err error)

Unlock unlocks the mutex

type MutexOptions

type MutexOptions struct {
	Key     string
	Sleep   time.Duration
	Timeout time.Duration
}

MutexOptions represents mutex options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL