Esempio n. 1
0
File: cache.go Progetto: Gr1N/pacman
// Init initializes application cache.
func Init() {
	caches := settings.S.Cache

	expiration, _ := time.ParseDuration(caches.DefaultExpiration)
	c = cache.NewRedisCache(
		caches.Host,
		caches.Password,
		expiration)
}
Esempio n. 2
0
func init() {
	Logger.Info("init cache ...")
	Cache = cache.NewRedisCache(config.AuthPageConfig.RedisHost, config.AuthPageConfig.RedisPassword, constant.LOGIN_EXPIRED_TIME)
	if err := Cache.Set("_test_is_valid_x_", "x", time.Second); err != nil {
		Logger.Error("error redis status,%v, will use memcached", err)
		Cache = cache.NewMemcachedStore(config.AuthPageConfig.MemcachedHosts, constant.LOGIN_EXPIRED_TIME)
		if err = Cache.Set("_test_is_valid_x_", "x", time.Second); err != nil {
			Logger.Error("error redis status,%v, will use memry cache", err)
			Cache = cache.NewInMemoryStore(constant.LOGIN_EXPIRED_TIME)
		}
	}

	Logger.Info("cache inited")
}
Esempio n. 3
0
File: cache.go Progetto: sdvdxl/wine
func init() {
	log.Logger.Info("init cache ...")
	//	Cache = cache.NewRedisCache("redis-31pzn.q1.tenxcloud.net:48181", "Isdvdxl8", constant.LOGIN_EXPIRED_TIME)
	Cache = cache.NewRedisCache("54.223.168.107:61993", "Isdvdxl8", constant.LOGIN_EXPIRED_TIME)
	if err := Cache.Set("_test_is_valid_x_", "x", time.Second); err != nil {
		log.Logger.Error("error redis status,%v, will use memcached", err)
		Cache = cache.NewMemcachedStore([]string{}, constant.LOGIN_EXPIRED_TIME)
		if err = Cache.Set("_test_is_valid_x_", "x", time.Second); err != nil {
			log.Logger.Error("error redis status,%v, will use memry cache", err)
			Cache = cache.NewInMemoryStore(constant.LOGIN_EXPIRED_TIME)
		}
	}

	log.Logger.Info("cache inited")
}