cacherepo

package
v0.0.0-...-a448e87 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheRepo

type CacheRepo struct {
	UserCacheRepo    IUserCacheRepo
	MessageCacheRepo IMessageCacheRepo
}

func NewCacheRepo

func NewCacheRepo(client *redis.Client, conn *gorm.DB) *CacheRepo

NewCacheRepo return cache repo

type IMessageCacheRepo

type IMessageCacheRepo interface {
	Subscribe(cvs *model.Conversation) (*redis.PubSub, error)
	Publish(msg *model.Message) error
}

type IUserCacheRepo

type IUserCacheRepo interface {
	DelAll()
	Set(key string, cacheUser *cachemodels.CachedUser, expiration time.Duration) error
	GetAllUserByKey(key string) ([]cachemodels.CachedUser, error)
	Sets(cachedUsers []cachemodels.CachedUser, expiration time.Duration)
	GenerateKey(sex bool, age int, username string, hobbies []model.Hobby) (strKey string)
	FindRelevant(user *model.User, hobbies []model.Hobby, exceptUser []cachemodels.CachedUser, nUser int) ([]cachemodels.CachedUser, error)
	UpdateExpirations(cUsers []cachemodels.CachedUser, expiration time.Duration)
	UpdateExpiration(cUser *cachemodels.CachedUser, expiration time.Duration)
	UpdateExpirationKey(key string, expiration time.Duration)
}

func NewUserRedisRepo

func NewUserRedisRepo(client *redis.Client, conn *gorm.DB) IUserCacheRepo

type MessageRedisRepo

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

func NewMessageRedisRepo

func NewMessageRedisRepo(client *redis.Client) *MessageRedisRepo

func (*MessageRedisRepo) Publish

func (mrr *MessageRedisRepo) Publish(msg *model.Message) error

func (*MessageRedisRepo) Subscribe

func (mrr *MessageRedisRepo) Subscribe(cvs *model.Conversation) (*redis.PubSub, error)

type UserRedisRepo

type UserRedisRepo struct {
	Client             *redis.Client
	CachedRepo         databaserepo.ICachedRepo
	UserRepo           databaserepo.IUserRepo
	HobbyRepo          databaserepo.IHobbyRepo
	LikeAndDislikeRepo databaserepo.ILikeAndDislikeRepo
}

func (*UserRedisRepo) DelAll

func (r *UserRedisRepo) DelAll()

DelAll delete all the keys of all the existing databases, not just the currently selected one. This command never fails

func (*UserRedisRepo) FindRelevant

func (r *UserRedisRepo) FindRelevant(user *model.User, hobbies []model.Hobby, exceptUser []cachemodels.CachedUser, nUser int) ([]cachemodels.CachedUser, error)

FindRelevant find nUser relevant

func (*UserRedisRepo) GenerateKey

func (*UserRedisRepo) GenerateKey(sex bool, age int, username string, hobbies []model.Hobby) (strKey string)

GenerateKey create key follow format: 'sex:age:hobby...:username'

func (*UserRedisRepo) GetAllUserByKey

func (r *UserRedisRepo) GetAllUserByKey(key string) ([]cachemodels.CachedUser, error)

GetAllUserByKey with key is key

func (*UserRedisRepo) GetKeysMatch

func (r *UserRedisRepo) GetKeysMatch(sex bool, age int, hobbies []model.Hobby) ([]string, error)

GetKeysMatch create pattern key follow format: 'sex:age:hobby...*'

func (*UserRedisRepo) Set

func (r *UserRedisRepo) Set(key string, cacheUser *cachemodels.CachedUser, expiration time.Duration) error

Set use SADD command to save data to set of redis

func (*UserRedisRepo) Sets

func (r *UserRedisRepo) Sets(cachedUsers []cachemodels.CachedUser, expiration time.Duration)

Sets save to cache

func (*UserRedisRepo) UpdateExpiration

func (r *UserRedisRepo) UpdateExpiration(cUser *cachemodels.CachedUser, expiration time.Duration)

func (*UserRedisRepo) UpdateExpirationKey

func (r *UserRedisRepo) UpdateExpirationKey(key string, expiration time.Duration)

func (*UserRedisRepo) UpdateExpirations

func (r *UserRedisRepo) UpdateExpirations(cUsers []cachemodels.CachedUser, expiration time.Duration)

Jump to

Keyboard shortcuts

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