Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const (
DefaultNamespace = "raus"
)
Variables ¶
Functions ¶
Types ¶
type Raus ¶
type Raus struct {
// contains filtered or unexported fields
}
func New ¶
New creates *Raus object.
Example ¶
package main import ( "context" "log" "sync" "github.com/fujiwara/raus" ) var redisURL = "redis://localhost:26379" func main() { // prepere context ctx, cancel := context.WithCancel(context.Background()) r, _ := raus.New(redisURL, 0, 3) id, ch, _ := r.Get(ctx) log.Printf("Got id %d", id) // watch error var wg sync.WaitGroup wg.Add(1) go func() { defer wg.Done() err, more := <-ch if !more { // raus shutdown successfully return } else { // fatal error panic(err) } }() // Run your application code // notify shutdown cancel() wg.Wait() }
Output:
type RedisClient ¶ added in v0.1.0
type RedisClient interface { Close() error Subscribe(ctx context.Context, channels ...string) *redis.PubSub SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.BoolCmd Get(ctx context.Context, key string) *redis.StringCmd Del(ctx context.Context, keys ...string) *redis.IntCmd Publish(ctx context.Context, channel string, message interface{}) *redis.IntCmd TxPipeline() redis.Pipeliner }
type RedisOptions ¶ added in v0.1.0
func ParseRedisURI ¶
func ParseRedisURI(s string) (*RedisOptions, string, error)
ParseRedisURI parses uri for redis (redis://host:port/db?ns=namespace)
func (*RedisOptions) NewClient ¶ added in v0.1.0
func (o *RedisOptions) NewClient() RedisClient
Click to show internal directories.
Click to hide internal directories.