Skip to content

Commit

Permalink
Redis cluster: Writes do not work, no analytics, no data.
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelycode committed Sep 11, 2015
1 parent f8c8824 commit 48ce2b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 2 additions & 0 deletions analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ func (m *MongoPurger) PurgeCache() {

AnalyticsValues := m.Store.GetAndDeleteSet(ANALYTICS_KEYNAME)

log.Warning(AnalyticsValues)

if len(AnalyticsValues) > 0 {
keys := make([]interface{}, len(AnalyticsValues), len(AnalyticsValues))

Expand Down
20 changes: 13 additions & 7 deletions redis_cluster_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,15 @@ func (r *RedisClusterStorageManager) Publish(channel string, message string) err

func (r *RedisClusterStorageManager) GetAndDeleteSet(keyName string) []interface{} {

log.Debug("Getting raw gkey set: ", keyName)
log.Info("Getting raw gkey set: ", keyName)
if r.db == nil {
log.Warning("Connection dropped, connecting..")
r.Connect()
r.GetAndDeleteSet(keyName)
} else {
log.Debug("keyName is: ", keyName)
log.Info("keyName is: ", keyName)
fixedKey := r.fixKey(keyName)
log.Debug("Fixed keyname is: ", fixedKey)
log.Info("Fixed keyname is: ", fixedKey)
r.db.Send("MULTI")
// Get all the elements
r.db.Send("LRANGE", fixedKey, 0, -1)
Expand All @@ -482,6 +482,7 @@ func (r *RedisClusterStorageManager) GetAndDeleteSet(keyName string) []interface
// Execute
r, err := redis.Values(r.db.Do("EXEC"))

log.Warning("Analytics returned: ", r)
if len(r) == 0 {
return []interface{}{}
}
Expand All @@ -501,17 +502,20 @@ func (r *RedisClusterStorageManager) GetAndDeleteSet(keyName string) []interface

func (r *RedisClusterStorageManager) AppendToSet(keyName string, value string) {

log.Debug("Pushing to raw key set: ", keyName)
log.Info("Pushing to raw key set: ", keyName)
log.Info("Pushing to fixed key set: ", r.fixKey(keyName))
if r.db == nil {
log.Warning("Connection dropped, connecting..")
r.Connect()
r.AppendToSet(keyName, value)
} else {
_, err := r.db.Do("RPUSH", r.fixKey(keyName), value)
ret, err := r.db.Do("RPUSH", r.fixKey(keyName), value)

log.Warning(ret)

if err != nil {
log.Debug("Error trying to delete keys:")
log.Debug(err)
log.Error("Error trying to delete keys:")
log.Error(err)
}

return
Expand Down Expand Up @@ -544,6 +548,8 @@ func (r *RedisClusterStorageManager) SetRollingWindow(keyName string, per int64,
r.db.Send("EXPIRE", keyName, per)
r, err := redis.Values(r.db.Do("EXEC"))

log.Warning(r)

intVal := len(r[1].([]interface{}))

log.Debug("Returned: ", intVal)
Expand Down

0 comments on commit 48ce2b0

Please sign in to comment.