cache

package
v1.9.6 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 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 Cache

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

Cache allows operating the chats and users cache in a thread-safe manner

func NewCache

func NewCache() *Cache

NewCache initializes a cache

func (*Cache) ChatsKeys

func (cache *Cache) ChatsKeys() []int64

ChatsKeys grabs chat ids synchronously to avoid lockups while they are used

func (*Cache) GetChat

func (cache *Cache) GetChat(id int64) (*client.Chat, bool)

GetChat retrieves chat by id if it's present in the cache

func (*Cache) GetStatus

func (cache *Cache) GetStatus(id int64) (*Status, bool)

GetStatus retrieves status by id if it's present in the cache

func (*Cache) GetUser

func (cache *Cache) GetUser(id int64) (*client.User, bool)

GetUser retrieves user by id if it's present in the cache

func (*Cache) SetChat

func (cache *Cache) SetChat(id int64, chat *client.Chat)

SetChat stores a chat in the cache

func (*Cache) SetStatus

func (cache *Cache) SetStatus(id int64, show string, status string)

SetStatus stores a status in the cache

func (*Cache) SetUser

func (cache *Cache) SetUser(id int64, user *client.User)

SetUser stores a user in the cache

func (*Cache) StatusesRange

func (cache *Cache) StatusesRange() chan *Status

StatusesRange loops through the map in a thread-safe manner

func (*Cache) UsersKeys

func (cache *Cache) UsersKeys() []int64

UsersKeys grabs user ids synchronously to avoid lockups while they are used

type Status

type Status struct {
	ID          int64
	XMPP        string
	Description string
}

Status stores formatted data for XMPP presence

func (*Status) Destruct added in v1.7.5

func (status *Status) Destruct() (show, description, typ string)

Destruct splits a cached status into show, description and type

Jump to

Keyboard shortcuts

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