|
@@ -60,10 +60,11 @@ func GetNewestInfo(userId, userType string, newUserId int64) *NewestInfo {
|
|
|
// 根据GetPushHistoryCount 返回值 作为列表缓存key中一个参数
|
|
|
func (n *NewestInfo) GetPushHistoryCount() int64 {
|
|
|
countKey := fmt.Sprintf("push_count_%s_%s", n.TableName, n.UserId)
|
|
|
- if b := redis.GetInt("other", countKey); b > 0 {
|
|
|
- return int64(b)
|
|
|
+ if b, err := redis.Exists("other", countKey); err == nil && b {
|
|
|
+ return 1
|
|
|
}
|
|
|
- countSql := "select count(1) from %s a where a.userid=%d order by a.id desc"
|
|
|
+ countSql := "SELECT COUNT(1) FROM (SELECT 1 FROM %s WHERE s_userid = %d LIMIT 1) AS ph"
|
|
|
+ //countSql := "select count(1) from %s a where a.userid=%d order by a.id desc"
|
|
|
countSql = fmt.Sprintf(countSql, n.TableName, n.NewUserId)
|
|
|
if c := n.MysqlDb.CountBySql(countSql); c > 0 {
|
|
|
redis.Put("other", countKey, c, 60) //过期时间走配置,比最新标讯列表缓存时间 要短1/10 尽量不超过两分钟
|