Documentation
¶
Index ¶
- Constants
- func TimelineKey(userID uint) string
- func TweetKey(tweetID uuid.UUID) string
- func UserFollowersKey(userID uint) string
- type IRepository
- type Repository
- func (repository Repository) AddFollower(userID, newFollowerID uint) error
- func (repository Repository) AddTweetToTimeline(tweetID uuid.UUID, userID uint) error
- func (repository Repository) CreateTweet(tweet models.Tweet) (uuid.UUID, error)
- func (repository Repository) GetFollowers(userID uint) ([]uint, error)
- func (repository Repository) GetTimeline(userID uint) ([]uuid.UUID, error)
- func (repository Repository) GetTweets(ids []uuid.UUID) ([]models.Tweet, error)
Constants ¶
View Source
const ( Forever = 0 // Forever indicates an infinite TTL TweetTTL = 2 * time.Hour MaxTweetsInTimeline = 40 )
Variables ¶
This section is empty.
Functions ¶
func TimelineKey ¶
TimelineKey returns the key that stores an user's timeline
func UserFollowersKey ¶
UserFollowersKey returns the key that stores the list of followers of userID in the cache
Types ¶
type IRepository ¶
type IRepository interface { // AddFollower adds newFollowerID to the list of followers of userID AddFollower(userID, newFollowerID uint) error // GetFollowers returns the list of followers of user userID GetFollowers(userID uint) ([]uint, error) // CreateTweet creates a tweet returning its id CreateTweet(tweet models.Tweet) (uuid.UUID, error) // GetTweets returns a list of tweets by their ids GetTweets(ids []uuid.UUID) ([]models.Tweet, error) // AddTweetToTimeline adds a tweetID to the user's timeline, maintaining a maximin length of 40 tweets AddTweetToTimeline(tweetID uuid.UUID, userID uint) error // GetTimeline returns the list of tweets ids in a user timeline GetTimeline(userID uint) ([]uuid.UUID, error) }
type Repository ¶
type Repository struct {
RDB *redis.Client
}
func (Repository) AddFollower ¶
func (repository Repository) AddFollower(userID, newFollowerID uint) error
AddFollower adds newFollowerID to the list of followers of userID
func (Repository) AddTweetToTimeline ¶
func (repository Repository) AddTweetToTimeline(tweetID uuid.UUID, userID uint) error
AddTweetToTimeline adds a tweetID to the user's timeline, maintaining a maximin length of 40 tweets
func (Repository) CreateTweet ¶
CreateTweet creates a tweet returning its id
func (Repository) GetFollowers ¶
func (repository Repository) GetFollowers(userID uint) ([]uint, error)
GetFollowers returns the list of followers of user userID
func (Repository) GetTimeline ¶
func (repository Repository) GetTimeline(userID uint) ([]uuid.UUID, error)
GetTimeline returns the list of tweets ids in a user timeline
Click to show internal directories.
Click to hide internal directories.