-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentry.go
More file actions
38 lines (33 loc) · 807 Bytes
/
entry.go
File metadata and controls
38 lines (33 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package cbytecache
import "github.com/koykov/indirect"
// Internal entry object.
type entry struct {
// Hash of entry key. Uses to link entry with index map.
hash uint64
// Entry data offset in arena.
offset uint32
// Entry length in arena(-s).
length uint32
// Expiration timestamp. Will overflow at 2106-02-07 06:28:15
expire uint32
// Arena index in queue storage.
aid uint32
// Queue raw pointer.
qp uintptr
}
// Get starting arena contains entry data.
func (e *entry) arena() *arena {
raw := indirect.ToUnsafePtr(e.qp)
q := (*arenaQueue)(raw)
return q.get(int64(e.aid))
}
// Make entry invalid.
func (e *entry) destroy() {
e.hash = 0
}
// Check entry is invalid.
//
// Allows to skip processing of previously deleted entries.
func (e *entry) invalid() bool {
return e.hash == 0
}