Пример #1
0
func TestDeadClient(t *testing.T) {
	server, client := redistest.NewServerClient(t)
	server.Close()
	store := bytestore.New(client)
	const key = "key"
	_, err := store.Get(key)
	if err == nil {
		t.Fatal("was expecting error")
	}
}
Пример #2
0
func TestGetMissing(t *testing.T) {
	server, client := redistest.NewServerClient(t)
	defer server.Close()
	store := bytestore.New(client)
	const key = "key"
	actual, err := store.Get(key)
	if err != nil {
		t.Fatal(err)
	}
	if actual != nil {
		t.Fatalf("found %s instead of nil", actual)
	}
}
Пример #3
0
func TestSetGet(t *testing.T) {
	server, client := redistest.NewServerClient(t)
	defer server.Close()
	store := bytestore.New(client)
	const key = "key"
	expected := []byte("data")
	if err := store.Store(key, expected); err != nil {
		t.Fatal(err)
	}
	actual, err := store.Get(key)
	if err != nil {
		t.Fatal(err)
	}
	if !bytes.Equal(actual, expected) {
		t.Fatalf("found %s instead of %s", actual, expected)
	}
}
Пример #4
0
// Package service provides configured service instances.
package service

import (
	"github.com/daaku/go.redis"
	"github.com/daaku/go.redis/bytecache"
	"github.com/daaku/go.redis/bytestore"
	"github.com/daaku/go.static"
	"github.com/daaku/go.stats/stathatbackend"
)

var (
	Static    = static.HandlerFlag("rell.static")
	Stats     = stathatbackend.EZKeyFlag("rell.stats")
	Redis     = redis.ClientFlag("rell.redis")
	ByteCache = bytecache.New(Redis)
	ByteStore = bytestore.New(Redis)
)

func init() {
	Redis.Stats = Stats
}