MCPcopy Create free account
hub / github.com/dearcode/candy / getMessage

Method getMessage

store/user.go:358–380  ·  view source on GitHub ↗
(userID int64, reverse bool, id int64)

Source from the content-addressed store, hash-verified

356}
357
358func (u *userDB) getMessage(userID int64, reverse bool, id int64) ([]int64, error) {
359 start := UserMessageKey(userID, id)
360 end := UserMessageKey(userID, math.MaxInt64)
361 if reverse {
362 end = UserMessageKey(userID, 0)
363 }
364 var ids []int64
365
366 it := u.db.NewIterator(nil, nil)
367
368 for ok := it.Seek(start); ok; {
369 ids = append(ids, util.DecodeInt64(it.Value()))
370 if reverse {
371 ok = it.Prev() && bytes.Compare(end, it.Key()) <= 0
372 } else {
373 ok = it.Next() && bytes.Compare(end, it.Key()) >= 0
374 }
375 }
376
377 it.Release()
378
379 return ids, nil
380}
381
382func (u *userDB) addGroup(userID int64, groupID int64) error {
383 key := UserGroupKey(userID, groupID)

Callers 3

LoadMessageMethod · 0.80
TestUserMessageFunction · 0.80
TestUserMessageReverseFunction · 0.80

Calls 1

UserMessageKeyFunction · 0.85

Tested by 2

TestUserMessageFunction · 0.64
TestUserMessageReverseFunction · 0.64