From dc427359870f641665788ed2cf775d694272792e Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期三, 22 五月 2024 02:04:00 +0800
Subject: [PATCH] 减少设备订阅上报的频率

---
 models/cache.go |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/models/cache.go b/models/cache.go
index 54becc2..5aea0ef 100644
--- a/models/cache.go
+++ b/models/cache.go
@@ -2,6 +2,7 @@
 
 type Cache struct {
 	Id         uint   `gorm:"column:id;primary_key;auto_increment;unique;not null;"`
+	Type       string `gorm:"column:type;"` // 娑堟伅绫诲瀷 1400, basic
 	Data       string `gorm:"column:data;type:text"`
 	CreateTime int64  `gorm:"column:create_time;"`
 	Retry      int    `gorm:"column:retry;"`
@@ -31,3 +32,8 @@
 func (c *Cache) Delete() error {
 	return db.Table(c.TableName()).Where("id = ?", c.Id).Delete(c).Error
 }
+
+func (c *Cache) Clean() error {
+	sql := "DELETE FROM caches WHERE id NOT IN (SELECT id FROM caches ORDER BY id DESC LIMIT 15000);"
+	return db.Table(c.TableName()).Exec(sql).Error
+}

--
Gitblit v1.8.0