| 254 | } |
| 255 | |
| 256 | func (this *SQLiteFileListDB) ListLFUItems(count int) (hashList []string, err error) { |
| 257 | if !this.isReady { |
| 258 | return nil, nil |
| 259 | } |
| 260 | |
| 261 | if count <= 0 { |
| 262 | count = 100 |
| 263 | } |
| 264 | |
| 265 | // 先找过期的 |
| 266 | hashList, err = this.ListExpiredItems(count) |
| 267 | if err != nil { |
| 268 | return |
| 269 | } |
| 270 | var l = len(hashList) |
| 271 | |
| 272 | // 从旧缓存中补充 |
| 273 | if l < count { |
| 274 | oldHashList, err := this.listOlderItems(count - l) |
| 275 | if err != nil { |
| 276 | return nil, err |
| 277 | } |
| 278 | hashList = append(hashList, oldHashList...) |
| 279 | } |
| 280 | |
| 281 | return hashList, nil |
| 282 | } |
| 283 | |
| 284 | func (this *SQLiteFileListDB) ListHashes(lastId int64) (hashList []string, maxId int64, err error) { |
| 285 | rows, err := this.selectHashListStmt.Query(lastId) |