(seg *segment, slotId int)
| 51 | } |
| 52 | |
| 53 | func (it *Iterator) nextForSlot(seg *segment, slotId int) *Entry { |
| 54 | slotOff := int32(it.slotIdx) * seg.slotCap |
| 55 | slot := seg.slotsData[slotOff : slotOff+seg.slotLens[it.slotIdx] : slotOff+seg.slotCap] |
| 56 | for it.entryIdx < len(slot) { |
| 57 | ptr := slot[it.entryIdx] |
| 58 | it.entryIdx++ |
| 59 | now := seg.timer.Now() |
| 60 | var hdrBuf [ENTRY_HDR_SIZE]byte |
| 61 | seg.rb.ReadAt(hdrBuf[:], ptr.offset) |
| 62 | hdr := (*entryHdr)(unsafe.Pointer(&hdrBuf[0])) |
| 63 | if hdr.expireAt == 0 || hdr.expireAt > now { |
| 64 | entry := new(Entry) |
| 65 | entry.Key = make([]byte, hdr.keyLen) |
| 66 | entry.Value = make([]byte, hdr.valLen) |
| 67 | entry.ExpireAt = hdr.expireAt |
| 68 | seg.rb.ReadAt(entry.Key, ptr.offset+ENTRY_HDR_SIZE) |
| 69 | seg.rb.ReadAt(entry.Value, ptr.offset+ENTRY_HDR_SIZE+int64(hdr.keyLen)) |
| 70 | return entry |
| 71 | } |
| 72 | } |
| 73 | return nil |
| 74 | } |
| 75 | |
| 76 | // NewIterator creates a new iterator for the cache. |
| 77 | func (cache *Cache) NewIterator() *Iterator { |
no test coverage detected