github.com/leslie-fei/fastcache@v0.0.0-20240520092641-b7a9eb05711f/node.go (about)

     1  package fastcache
     2  
     3  import (
     4  	"unsafe"
     5  )
     6  
     7  // DataNode 用来存储对应数据的数据链表节点
     8  type DataNode struct {
     9  	Next           uint64
    10  	Len            uint32
    11  	FreeBlockIndex uint8
    12  }
    13  
    14  func (ln *DataNode) Reset() {
    15  	ln.Next = 0
    16  	ln.Len = 0
    17  }
    18  
    19  func (ln *DataNode) Offset(base uintptr) uint64 {
    20  	return uint64(uintptr(unsafe.Pointer(ln)) - base)
    21  }