cache

package
v0.0.0-...-24633da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NoteCache

type NoteCache struct {
	// contains filtered or unexported fields
}

Note cache stat representation states:

sorted set: {{list.0, score0}, {list.1, score1}, {list.2, score2}}

list:

list.0: [{"nid": "xxx", "inc": 1}, {"nid": "xxx", "inc": 1}]
list.1: [{"nid": "xxx", "inc": -1}, {"nid": "xxx", "inc": -1}]
list.2: [{"nid": "xxx", "inc": 1}, {"nid": "xxx", "inc": -1}]

func NewNoteCache

func NewNoteCache(numOfList uint32) *NoteCache

func (*NoteCache) Add

func (b *NoteCache) Add(ctx context.Context,
	statType NoteInteractStatType, stat NoteStatRepr) error

数据先行写入redis

func (*NoteCache) ConsumeCommentCount

func (b *NoteCache) ConsumeCommentCount(ctx context.Context, want int) ([]NoteStatRepr, error)

func (*NoteCache) ConsumeLikeCount

func (b *NoteCache) ConsumeLikeCount(ctx context.Context, want int) ([]NoteStatRepr, error)

type NoteInteractStatType

type NoteInteractStatType string
const (
	NoteLikeCountStat    NoteInteractStatType = "note_like"
	NoteCommentCountStat NoteInteractStatType = "note_comment"
)

type NoteStatRepr

type NoteStatRepr struct {
	Type   NoteInteractStatType `json:"-"`
	NoteId string               `json:"nid"` // note_id
	Inc    int64                `json:"inc"` // increment
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL