package entity import ( "app.yhyue.com/moapp/MessageCenter/rpc/type/message" "app.yhyue.com/moapp/jybase/redis" "encoding/json" "fmt" ) const ( Date_Full_Layout = "2006-01-02 15:04:05" SOCIALIZE_CHAT_SESSION = "socialize_chat_session" SOCIALIZE_MESSAGE = "socialize_message" SOCIALIZE_MESSAGE_MAILBOX = "socialize_message_mailbox" SOCIALIZE_TENANT_ROBOT = "socialize_tenant_robot" BASE_USER = "base_user" ) const ( SUCCESS_CODE = int64(0) ERROR_CODE = int64(1) ) const redisModule = "msgCount" type SubPush struct { Data []*message.Messages `json:"data"` Count int64 `json:"count"` } // 获取redis key func todayKey(userId string) string { return fmt.Sprintf("%s_%s", "messageCount", userId) } func GetData(userId string) (*SubPush, error) { pc_a, err := redis.GetNewBytes(redisModule, todayKey(userId)) if err != nil { return nil, err } if pc_a == nil { return nil, nil } var p *SubPush if err := json.Unmarshal(*pc_a, &p); err != nil { return nil, err } return p, nil } func SetData(userId string, data map[string]interface{}, survivalTime int) { redis.Put(redisModule, todayKey(userId), data, survivalTime) }