Documentation ¶
Overview ¶
Package redisHelpers is a package for wrapping redis functionality.
Copyright 2018 Google LLC ¶
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 ¶
- func ConnectionPool(cfg *viper.Viper) *redis.Pool
- func Count(ctx context.Context, pool *redis.Pool, key string) (int, error)
- func Create(ctx context.Context, pool *redis.Pool, key string, values map[string]string) (string, error)
- func Decrement(ctx context.Context, pool *redis.Pool, key string) (interface{}, error)
- func Delete(ctx context.Context, pool *redis.Pool, key string) error
- func DeleteMultiFields(ctx context.Context, pool *redis.Pool, keys []string, field string) error
- func Increment(ctx context.Context, pool *redis.Pool, key string) (interface{}, error)
- func JSONStringToMap(result string) map[string]interface{}
- func Retrieve(ctx context.Context, pool *redis.Pool, key string) (string, error)
- func RetrieveAll(ctx context.Context, pool *redis.Pool, key string) (map[string]string, error)
- func RetrieveField(ctx context.Context, pool *redis.Pool, key string, field string) (string, error)
- func Update(ctx context.Context, pool *redis.Pool, key string, value string) (string, error)
- func UpdateMultiFields(ctx context.Context, pool *redis.Pool, kv map[string]string, field string) error
- func Watcher(ctx context.Context, pool *redis.Pool, key string) <-chan string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectionPool ¶
ConnectionPool reads the configuration and attempts to instantiate a redis connection pool based on the configured hostname and port.
func Create ¶
func Create(ctx context.Context, pool *redis.Pool, key string, values map[string]string) (string, error)
Create is a concurrent-safe, context-aware redis SET of the input key to the input value
func DeleteMultiFields ¶
DeleteMultiFields is a concurrent-safe, context-aware Redis DEL of the input field from the input keys
func JSONStringToMap ¶
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 RetrieveAll ¶
RetrieveAll is a concurrent-safe, context-aware redis HGETALL on the input key
func RetrieveField ¶
RetrieveField is a concurrent-safe, context-aware redis HGET on the input field of the input key
func Update ¶
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 UpdateMultiFields ¶
func UpdateMultiFields(ctx context.Context, pool *redis.Pool, kv map[string]string, field string) error
UpdateMultiFields is a concurrent-safe, context-aware Redis HSET of the input field Keys to update and the values to set the field to are passed in the 'kv' map. Example usage is to set multiple player's "assignment" field to various game server connection strings. "field" := "assignment" "kv" := map[string]string{ "player1": "servername:10000", "player2": "otherservername:10002" }
func Watcher ¶
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 ignorelist is an ignore list specific redis implementation and will be removed in a future version.
|
Package ignorelist is an ignore list specific redis implementation and will be removed in a future version. |
Package playerindices indexes player attributes in Redis for faster filtering of player pools.
|
Package playerindices indexes player attributes in Redis for faster filtering of player pools. |
Package redispb marshals and unmarshals Open Match Backend protobuf messages ('MatchObject') for redis state storage.
|
Package redispb marshals and unmarshals Open Match Backend protobuf messages ('MatchObject') for redis state storage. |