func (c Radio) LogVisitorByIP() revel.Result { rdal, err := models.NewRedisDal() if err != nil { return nil } defer rdal.Close() ip := policy.FilterIp(c.Request.RemoteAddr) rdal.Incr(ip) return nil }
func (c Stat) Self() revel.Result { rdal, err := models.NewRedisDal() if err != nil { return c.RenderJson(err) } defer rdal.Close() ip := policy.FilterIp(c.Request.RemoteAddr) counter, err := rdal.Get(ip) if err != nil { return c.RenderJson(err) } result := models.StatSelfResult{} result.IP = ip result.Counter, _ = strconv.Atoi(counter) return c.RenderJson(result) }
func (c Stat) All() revel.Result { rdal, err := models.NewRedisDal() if err != nil { return c.RenderJson(err) } defer rdal.Close() result := models.StatAllResult{} result.Detail = make(map[string]int) keys, err := rdal.Keys("*") if err != nil { return c.RenderJson(err) } for _, key := range keys { count, _ := rdal.Get(key) count_i, _ := strconv.Atoi(count) result.Detail[key] = count_i result.TotalCount += count_i } return c.RenderJson(result) }