@@ -99,7 +99,7 @@ func (seg *segment) set(key, value []byte, hashVal uint64, expireSeconds int) (e
99
99
hdr .expireAt = expireAt
100
100
hdr .valLen = uint32 (len (value ))
101
101
if hdr .valCap >= hdr .valLen {
102
- //in place overwrite
102
+ // in place overwrite
103
103
atomic .AddInt64 (& seg .totalTime , int64 (hdr .accessTime )- int64 (originAccessTime ))
104
104
seg .rb .WriteAt (hdrBuf [:], matchedPtr .offset )
105
105
seg .rb .WriteAt (value , matchedPtr .offset + ENTRY_HDR_SIZE + int64 (hdr .keyLen ))
@@ -186,7 +186,7 @@ func (seg *segment) touch(key []byte, hashVal uint64, expireSeconds int) (err er
186
186
originAccessTime := hdr .accessTime
187
187
hdr .accessTime = now
188
188
hdr .expireAt = expireAt
189
- //in place overwrite
189
+ // in place overwrite
190
190
atomic .AddInt64 (& seg .totalTime , int64 (hdr .accessTime )- int64 (originAccessTime ))
191
191
seg .rb .WriteAt (hdrBuf [:], matchedPtr .offset )
192
192
atomic .AddInt64 (& seg .touched , 1 )
@@ -236,7 +236,7 @@ func (seg *segment) evacuate(entryLen int64, slotId uint8, now uint32) (slotModi
236
236
}
237
237
238
238
func (seg * segment ) get (key , buf []byte , hashVal uint64 , peek bool ) (value []byte , expireAt uint32 , err error ) {
239
- hdr , ptr , err := seg .locate (key , hashVal , peek )
239
+ hdr , ptrOffset , err := seg .locate (key , hashVal , peek )
240
240
if err != nil {
241
241
return
242
242
}
@@ -247,7 +247,7 @@ func (seg *segment) get(key, buf []byte, hashVal uint64, peek bool) (value []byt
247
247
value = make ([]byte , hdr .valLen )
248
248
}
249
249
250
- seg .rb .ReadAt (value , ptr . offset + ENTRY_HDR_SIZE + int64 (hdr .keyLen ))
250
+ seg .rb .ReadAt (value , ptrOffset + ENTRY_HDR_SIZE + int64 (hdr .keyLen ))
251
251
if ! peek {
252
252
atomic .AddInt64 (& seg .hitCount , 1 )
253
253
}
@@ -257,11 +257,11 @@ func (seg *segment) get(key, buf []byte, hashVal uint64, peek bool) (value []byt
257
257
// view provides zero-copy access to the element's value, without copying to
258
258
// an intermediate buffer.
259
259
func (seg * segment ) view (key []byte , fn func ([]byte ) error , hashVal uint64 , peek bool ) (err error ) {
260
- hdr , ptr , err := seg .locate (key , hashVal , peek )
260
+ hdr , ptrOffset , err := seg .locate (key , hashVal , peek )
261
261
if err != nil {
262
262
return
263
263
}
264
- start := ptr . offset + ENTRY_HDR_SIZE + int64 (hdr .keyLen )
264
+ start := ptrOffset + ENTRY_HDR_SIZE + int64 (hdr .keyLen )
265
265
val , err := seg .rb .Slice (start , int64 (hdr .valLen ))
266
266
if err != nil {
267
267
return err
@@ -273,7 +273,7 @@ func (seg *segment) view(key []byte, fn func([]byte) error, hashVal uint64, peek
273
273
return
274
274
}
275
275
276
- func (seg * segment ) locate (key []byte , hashVal uint64 , peek bool ) (hdr * entryHdr , ptr * entryPtr , err error ) {
276
+ func (seg * segment ) locate (key []byte , hashVal uint64 , peek bool ) (hdrEntry entryHdr , ptrOffset int64 , err error ) {
277
277
slotId := uint8 (hashVal >> 8 )
278
278
hash16 := uint16 (hashVal >> 16 )
279
279
slot := seg .getSlot (slotId )
@@ -285,11 +285,11 @@ func (seg *segment) locate(key []byte, hashVal uint64, peek bool) (hdr *entryHdr
285
285
}
286
286
return
287
287
}
288
- ptr = & slot [idx ]
288
+ ptr : = & slot [idx ]
289
289
290
290
var hdrBuf [ENTRY_HDR_SIZE ]byte
291
291
seg .rb .ReadAt (hdrBuf [:], ptr .offset )
292
- hdr = (* entryHdr )(unsafe .Pointer (& hdrBuf [0 ]))
292
+ hdr : = (* entryHdr )(unsafe .Pointer (& hdrBuf [0 ]))
293
293
if ! peek {
294
294
now := seg .timer .Now ()
295
295
if isExpired (hdr .expireAt , now ) {
@@ -303,7 +303,7 @@ func (seg *segment) locate(key []byte, hashVal uint64, peek bool) (hdr *entryHdr
303
303
hdr .accessTime = now
304
304
seg .rb .WriteAt (hdrBuf [:], ptr .offset )
305
305
}
306
- return hdr , ptr , err
306
+ return * hdr , ptr . offset , nil
307
307
}
308
308
309
309
func (seg * segment ) del (key []byte , hashVal uint64 ) (affected bool ) {
0 commit comments