Esempio n. 1
0
func New(config *config.Config) *ReliableGet {
	g := &ReliableGet{}
	g.config = config
	g.factory = cache.NewCacheFactory()
	g.cache = g.factory.GetCache(&config.Cache)
	return g
}
Esempio n. 2
0
	"github.com/caledhwa/gongeal/reliableget/cache"
	"github.com/caledhwa/gongeal/reliableget/config"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"testing"
)

func TestCacheFactory(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "TestCacheFactory")
}

var _ = Describe("Cache Factory", func() {

	It("should return redis cache engine when specified in config", func() {
		cacheFactory := cache.NewCacheFactory()
		engine := cacheFactory.GetCache(&config.Cache{
			Engine: "redis",
		}).(cache.CacheEngine)
		Expect(engine.Engine()).To(BeEquivalentTo("redis"))
	})

	It("should return memory cache engine when specified in config", func() {
		cacheFactory := cache.NewCacheFactory()
		engine := cacheFactory.GetCache(&config.Cache{
			Engine: "memorycache",
		}).(cache.CacheEngine)
		Expect(engine.Engine()).To(BeEquivalentTo("memorycache"))
	})

	It("should return nocache engine when no config specified", func() {