redisHelpers

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

redisHelpers is a package for wrapping redis functionality.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectionPool

func ConnectionPool(cfg *viper.Viper) *redis.Pool

ConnectionPool reads the configuration and attempts to instantiate a redis connection pool based on the configured hostname and port. TODO: needs to be reworked to use redis sentinel when we're ready to support it.

func Count

func Count(ctx context.Context, pool *redis.Pool, key string) (int, error)

Count is a concurrent-safe, context-aware redis SCARD on the input key

func Create

func Create(ctx context.Context, pool *redis.Pool, key string, value string) (string, error)

Create is a concurrent-safe, context-aware redis SET of the input key to the input value

func Decrement

func Decrement(ctx context.Context, pool *redis.Pool, key string) (string, error)

Decrement decrements a redis value at key.

func Delete

func Delete(ctx context.Context, pool *redis.Pool, key string) (string, error)

Delete is a concurrent-safe, context-aware redis DEL on the input key

func Increment

func Increment(ctx context.Context, pool *redis.Pool, key string) (string, error)

Increment increments a redis value at key.

func JSONStringToMap

func JSONStringToMap(result string) map[string]interface{}

JSONStringToMap converts a JSON blob (which is how we store many things in redis) to a golang map so the individual properties can be accessed. Useful helper function when debugging.

func Retrieve

func Retrieve(ctx context.Context, pool *redis.Pool, key string) (string, error)

Retrieve is a concurrent-safe, context-aware redis GET on the input key

func Update

func Update(ctx context.Context, pool *redis.Pool, key string, value string) (string, error)

Update is a concurrent-safe, context-aware redis SADD of the input value to the input key's set. (Yes, it is an imperfect mapping, likely rework this at some point)

func Watcher

func Watcher(ctx context.Context, pool *redis.Pool, key string) <-chan string

Watcher makes a channel and returns it immediately. It also launches an asynchronous goroutine that watches a redis key and returns the value of that key once it exists on the channel.

The pattern for this function is from 'Go Concurrency Patterns', it is a function that wraps a closure goroutine, and returns a channel. reference: https://talks.golang.org/2012/concurrency.slide#25

Types

This section is empty.

Directories

Path Synopsis
Package playerq is a player queue specific redis implementation and will be removed in a future version.
Package playerq is a player queue specific redis implementation and will be removed in a future version.

Jump to

Keyboard shortcuts

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