redis

package
v0.0.0-...-707b42e Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TTL for different message types
	KeyDistributionTTL = 24 * time.Hour     // Key distribution messages expire after 24 hours
	RegularDMTTL       = 7 * 24 * time.Hour // Regular DMs expire after 7 days

)

Variables

This section is empty.

Functions

This section is empty.

Types

type DMStore

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

func NewDMStore

func NewDMStore(rdb *redis.Client) *DMStore

func (*DMStore) CleanupExpiredMessages

func (s *DMStore) CleanupExpiredMessages() error

CleanupExpiredMessages removes expired message IDs from queues This should be run periodically as a background job

func (*DMStore) DeleteDMForUser

func (s *DMStore) DeleteDMForUser(messageID, userID string) error

DeleteDMForUser removes a message from user's queue

func (*DMStore) DeleteDMsBetweenUsers

func (s *DMStore) DeleteDMsBetweenUsers(user1, user2 string) error

func (*DMStore) GetDMsBetweenUsers

func (s *DMStore) GetDMsBetweenUsers(userID1, userID2 string, limit int) ([]models.EncryptedDM, error)

GetDMsBetweenUsers retrieves conversation between two users

func (*DMStore) GetDMsForUser

func (s *DMStore) GetDMsForUser(userID string, messageType string, limit int) ([]models.EncryptedDM, error)

GetDMsForUser retrieves DMs for a user from their queue

func (*DMStore) GetUnreadCount

func (s *DMStore) GetUnreadCount(userID string) (int64, error)

GetUnreadCount returns the number of unread messages for a user

func (*DMStore) MarkDMAsRead

func (s *DMStore) MarkDMAsRead(messageID, userID string) error

MarkDMAsRead marks a message as read

func (*DMStore) SaveDM

func (s *DMStore) SaveDM(dm models.EncryptedDM) error

SaveDM stores an encrypted DM in Redis with appropriate TTL

func (*DMStore) SubscribeToDMs

func (s *DMStore) SubscribeToDMs(userID string) *redis.PubSub

SubscribeToDMs subscribes to real-time DM notifications for a user

Jump to

Keyboard shortcuts

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