| | |
| | | return caches, nil |
| | | } |
| | | |
| | | func (c *Cache) Update() error { |
| | | return db.Table(c.TableName()).Save(&c).Error |
| | | func (c *Cache) UpdateRetryCount() error { |
| | | return db.Table(c.TableName()).Update("retry", c.Retry+1).Error |
| | | } |
| | | |
| | | func (c *Cache) Delete() error { |
| | |
| | | for _, c := range cacheItems { |
| | | if !util.SendData([]byte(c.Data), config.ForwardConf.SyncServer) { |
| | | logger.Warn("The data resend failed. retry count %d", c.Retry) |
| | | |
| | | c.Retry = c.Retry + 1 |
| | | c.Update() |
| | | c.UpdateRetryCount() |
| | | } else { |
| | | c.Delete() |
| | | logger.Debug("The data resend successful.") |