cache

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EDUCache

type EDUCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

EDUCache maintains a list of users typing in each room.

func New

func New() *EDUCache

New returns a new EDUCache initialised for use.

func (*EDUCache) AddTypingUser

func (t *EDUCache) AddTypingUser(
	userID, roomID string, expire *time.Time,
) int64

AddTypingUser sets an user as typing in a room. expire is the time when the user typing should time out. if expire is nil, defaultTypingTimeout is assumed. Returns the latest sync position for typing after update.

func (*EDUCache) GetLatestSyncPosition

func (t *EDUCache) GetLatestSyncPosition() int64

func (*EDUCache) GetTypingUsers

func (t *EDUCache) GetTypingUsers(roomID string) []string

GetTypingUsers returns the list of users typing in a room.

func (*EDUCache) GetTypingUsersIfUpdatedAfter

func (t *EDUCache) GetTypingUsersIfUpdatedAfter(
	roomID string, position int64,
) (users []string, updated bool)

GetTypingUsersIfUpdatedAfter returns all users typing in this room with updated == true if the typing sync position of the room is after the given position. Otherwise, returns an empty slice with updated == false.

func (*EDUCache) RemoveUser

func (t *EDUCache) RemoveUser(userID, roomID string) int64

RemoveUser with mutex lock & stop the timer. Returns the latest sync position for typing after update.

func (*EDUCache) SetTimeoutCallback

func (t *EDUCache) SetTimeoutCallback(fn TimeoutCallbackFn)

SetTimeoutCallback sets a callback function that is called right after a user is removed from the typing user list due to timeout.

type TimeoutCallbackFn

type TimeoutCallbackFn func(userID, roomID string, latestSyncPosition int64)

TimeoutCallbackFn is a function called right after the removal of a user from the typing user list due to timeout. latestSyncPosition is the typing sync position after the removal.

Jump to

Keyboard shortcuts

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