(key, buf []byte, hashVal uint64, peek bool)
| 236 | } |
| 237 | |
| 238 | func (seg *segment) get(key, buf []byte, hashVal uint64, peek bool) (value []byte, expireAt uint32, err error) { |
| 239 | hdr, ptrOffset, err := seg.locate(key, hashVal, peek) |
| 240 | if err != nil { |
| 241 | return |
| 242 | } |
| 243 | expireAt = hdr.expireAt |
| 244 | if cap(buf) >= int(hdr.valLen) { |
| 245 | value = buf[:hdr.valLen] |
| 246 | } else { |
| 247 | value = make([]byte, hdr.valLen) |
| 248 | } |
| 249 | |
| 250 | seg.rb.ReadAt(value, ptrOffset+ENTRY_HDR_SIZE+int64(hdr.keyLen)) |
| 251 | if !peek { |
| 252 | atomic.AddInt64(&seg.hitCount, 1) |
| 253 | } |
| 254 | return |
| 255 | } |
| 256 | |
| 257 | // view provides zero-copy access to the element's value, without copying to |
| 258 | // an intermediate buffer. |
no test coverage detected