SetBothLevels 更新内存和磁盘缓存
(key string, data []byte, ttl time.Duration)
| 73 | |
| 74 | // SetBothLevels 更新内存和磁盘缓存 |
| 75 | func (c *EnhancedTwoLevelCache) SetBothLevels(key string, data []byte, ttl time.Duration) error { |
| 76 | now := time.Now() |
| 77 | |
| 78 | // 同步更新内存缓存 |
| 79 | c.memory.SetWithTimestamp(key, data, ttl, now) |
| 80 | |
| 81 | // 同步更新磁盘缓存,确保数据立即写入 |
| 82 | return c.disk.Set(key, data, ttl) |
| 83 | } |
| 84 | |
| 85 | // SetWithFinalFlag 根据结果状态选择更新策略 |
| 86 | func (c *EnhancedTwoLevelCache) SetWithFinalFlag(key string, data []byte, ttl time.Duration, isFinal bool) error { |
no test coverage detected