Documentation ¶
Index ¶
- Constants
- Variables
- func BatchKey(prefix string, keys ...string) []string
- func GetScores(s []Scored) []float64
- func Key(keys ...string) string
- func RemoveScores(items []Scored) []string
- func SortScores(scores []Scored)
- type Database
- type MongoDB
- func (m MongoDB) AddSet(name string, members ...string) error
- func (m MongoDB) AddSorted(sortedSets ...SortedSet) error
- func (m MongoDB) Close() error
- func (m MongoDB) Delete(name string) error
- func (m MongoDB) Get(name string) *ReturnValue
- func (m MongoDB) GetSet(name string) ([]string, error)
- func (m MongoDB) GetSorted(name string, begin, end int) ([]Scored, error)
- func (m MongoDB) GetSortedByScore(name string, begin, end float64) ([]Scored, error)
- func (m MongoDB) Init() error
- func (m MongoDB) RemSet(name string, members ...string) error
- func (m MongoDB) RemSorted(members ...SetMember) error
- func (m MongoDB) RemSortedByScore(name string, begin, end float64) error
- func (m MongoDB) Scan(work func(string) error) error
- func (m MongoDB) Set(values ...Value) error
- func (m MongoDB) SetSet(name string, members ...string) error
- func (m MongoDB) SetSorted(name string, scores []Scored) error
- type NoDatabase
- func (NoDatabase) AddSet(_ string, _ ...string) error
- func (NoDatabase) AddSorted(_ ...SortedSet) error
- func (NoDatabase) Close() error
- func (NoDatabase) Delete(_ string) error
- func (NoDatabase) Get(_ string) *ReturnValue
- func (NoDatabase) GetSet(_ string) ([]string, error)
- func (NoDatabase) GetSorted(_ string, _, _ int) ([]Scored, error)
- func (NoDatabase) GetSortedByScore(_ string, _, _ float64) ([]Scored, error)
- func (NoDatabase) Init() error
- func (NoDatabase) RemSet(_ string, _ ...string) error
- func (NoDatabase) RemSorted(_ ...SetMember) error
- func (NoDatabase) RemSortedByScore(_ string, _, _ float64) error
- func (NoDatabase) Scan(_ func(string) error) error
- func (NoDatabase) Set(_ ...Value) error
- func (NoDatabase) SetSet(_ string, _ ...string) error
- func (NoDatabase) SetSorted(_ string, _ []Scored) error
- type Redis
- func (r *Redis) AddSet(key string, members ...string) error
- func (r *Redis) AddSorted(sortedSets ...SortedSet) error
- func (r *Redis) Close() error
- func (r *Redis) Delete(key string) error
- func (r *Redis) Get(key string) *ReturnValue
- func (r *Redis) GetSet(key string) ([]string, error)
- func (r *Redis) GetSorted(key string, begin, end int) ([]Scored, error)
- func (r *Redis) GetSortedByScore(key string, begin, end float64) ([]Scored, error)
- func (r *Redis) Init() error
- func (r *Redis) RemSet(key string, members ...string) error
- func (r *Redis) RemSorted(members ...SetMember) error
- func (r *Redis) RemSortedByScore(key string, begin, end float64) error
- func (r *Redis) Scan(work func(string) error) error
- func (r *Redis) Set(values ...Value) error
- func (r *Redis) SetSet(key string, members ...string) error
- func (r *Redis) SetSorted(key string, scores []Scored) error
- type ReturnValue
- type SQLDatabase
- func (db *SQLDatabase) AddSet(key string, members ...string) error
- func (db *SQLDatabase) AddSorted(sortedSets ...SortedSet) error
- func (db *SQLDatabase) Close() error
- func (db *SQLDatabase) Delete(name string) error
- func (db *SQLDatabase) Get(name string) *ReturnValue
- func (db *SQLDatabase) GetSet(key string) ([]string, error)
- func (db *SQLDatabase) GetSorted(key string, begin, end int) ([]Scored, error)
- func (db *SQLDatabase) GetSortedByScore(key string, begin, end float64) ([]Scored, error)
- func (db *SQLDatabase) Init() error
- func (db *SQLDatabase) RemSet(key string, members ...string) error
- func (db *SQLDatabase) RemSorted(members ...SetMember) error
- func (db *SQLDatabase) RemSortedByScore(key string, begin, end float64) error
- func (db *SQLDatabase) Scan(work func(string) error) error
- func (db *SQLDatabase) Set(values ...Value) error
- func (db *SQLDatabase) SetSet(key string, members ...string) error
- func (db *SQLDatabase) SetSorted(key string, scores []Scored) error
- type SQLDriver
- type SQLSet
- type SQLSortedSet
- type SQLValue
- type Scored
- type SetMember
- type SortedSet
- type Value
Constants ¶
const ( // Measurements are sorted set of measurements. // Measurements - measurements/{name} Measurements = "measurements" // IgnoreItems is sorted set of ignored items for each user // Ignored items - ignore_items/{user_id} IgnoreItems = "ignore_items" // HiddenItemsV2 is sorted set of hidden items. // Global hidden items - hidden_items_v2 // Category hidden items - hidden_items_v2/{category} HiddenItemsV2 = "hidden_items_v2" // ItemNeighbors is sorted set of neighbors for each item. // Global item neighbors - item_neighbors/{item_id} // Categorized item neighbors - item_neighbors/{item_id}/{category} ItemNeighbors = "item_neighbors" // ItemNeighborsDigest is digest of item neighbors configuration // Item neighbors digest - item_neighbors_digest/{item_id} ItemNeighborsDigest = "item_neighbors_digest" // UserNeighbors is sorted set of neighbors for each user. // User neighbors - user_neighbors/{user_id} UserNeighbors = "user_neighbors" // UserNeighborsDigest is digest of user neighbors configuration // User neighbors digest - user_neighbors_digest/{user_id} UserNeighborsDigest = "user_neighbors_digest" // CollaborativeRecommend is sorted set of collaborative filtering recommendations for each user. // Global recommendation - collaborative_recommend/{user_id} // Categorized recommendation - collaborative_recommend/{user_id}/{category} CollaborativeRecommend = "collaborative_recommend" // collaborative filtering recommendation for each user // OfflineRecommend is sorted set of offline recommendation for each user. // Global recommendation - offline_recommend/{user_id} // Categorized recommendation - offline_recommend/{user_id}/{category} OfflineRecommend = "offline_recommend" // OfflineRecommendDigest is digest of offline recommendation configuration. // Recommendation digest - offline_recommend_digest/{user_id} OfflineRecommendDigest = "offline_recommend_digest" // PopularItems is sorted set of popular items. The format of key: // Global popular items - latest_items // Categorized popular items - latest_items/{category} PopularItems = "popular_items" // LatestItems is sorted set of the latest items. The format of key: // Global latest items - latest_items // Categorized the latest items - latest_items/{category} LatestItems = "latest_items" // ItemCategories is the set of item categories. The format of key: // Global item categories - item_categories ItemCategories = "item_categories" LastModifyItemTime = "last_modify_item_time" // the latest timestamp that a user related data was modified LastModifyUserTime = "last_modify_user_time" // the latest timestamp that an item related data was modified LastUpdateUserRecommendTime = "last_update_user_recommend_time" // the latest timestamp that a user's recommendation was updated LastUpdateUserNeighborsTime = "last_update_user_neighbors_time" // the latest timestamp that a user's neighbors item was updated LastUpdateItemNeighborsTime = "last_update_item_neighbors_time" // the latest timestamp that an item's neighbors was updated // GlobalMeta is global meta information GlobalMeta = "global_meta" DataImported = "data_imported" NumUsers = "num_users" NumItems = "num_items" NumUserLabels = "num_user_labels" NumItemLabels = "num_item_labels" NumTotalPosFeedbacks = "num_total_pos_feedbacks" NumValidPosFeedbacks = "num_valid_pos_feedbacks" NumValidNegFeedbacks = "num_valid_neg_feedbacks" LastFitMatchingModelTime = "last_fit_matching_model_time" LastFitRankingModelTime = "last_fit_ranking_model_time" LastUpdateLatestItemsTime = "last_update_latest_items_time" // the latest timestamp that latest items were updated LastUpdatePopularItemsTime = "last_update_popular_items_time" // the latest timestamp that popular items were updated UserNeighborIndexRecall = "user_neighbor_index_recall" ItemNeighborIndexRecall = "item_neighbor_index_recall" MatchingIndexRecall = "matching_index_recall" )
Variables ¶
var ( ErrObjectNotExist = errors.NotFoundf("object") ErrNoDatabase = errors.NotAssignedf("database") )
Functions ¶
func GetScores ¶
GetScores resolve scores for a slice of Scored.
func RemoveScores ¶
RemoveScores resolve items for a slice of ScoredItems.
Types ¶
type Database ¶
type Database interface { Close() error Init() error Scan(work func(string) error) error Set(values ...Value) error Get(name string) *ReturnValue Delete(name string) error GetSet(key string) ([]string, error) SetSet(key string, members ...string) error AddSet(key string, members ...string) error RemSet(key string, members ...string) error AddSorted(sortedSets ...SortedSet) error GetSorted(key string, begin, end int) ([]Scored, error) GetSortedByScore(key string, begin, end float64) ([]Scored, error) RemSortedByScore(key string, begin, end float64) error SetSorted(key string, scores []Scored) error RemSorted(members ...SetMember) error }
Database is the common interface for cache store.
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
func (MongoDB) Get ¶
func (m MongoDB) Get(name string) *ReturnValue
func (MongoDB) GetSorted ¶
func (MongoDB) GetSortedByScore ¶
func (MongoDB) RemSortedByScore ¶
type NoDatabase ¶
type NoDatabase struct{}
NoDatabase means no database used for cache.
func (NoDatabase) AddSet ¶
func (NoDatabase) AddSet(_ string, _ ...string) error
AddSet method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) AddSorted ¶
func (NoDatabase) AddSorted(_ ...SortedSet) error
AddSorted method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) Close ¶
func (NoDatabase) Close() error
Close method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) Delete ¶
func (NoDatabase) Delete(_ string) error
Delete method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) Get ¶
func (NoDatabase) Get(_ string) *ReturnValue
Get method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetSet ¶
func (NoDatabase) GetSet(_ string) ([]string, error)
GetSet method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetSorted ¶
func (NoDatabase) GetSorted(_ string, _, _ int) ([]Scored, error)
GetSorted method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetSortedByScore ¶
func (NoDatabase) GetSortedByScore(_ string, _, _ float64) ([]Scored, error)
GetSortedByScore method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) Init ¶
func (NoDatabase) Init() error
Init method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) RemSet ¶
func (NoDatabase) RemSet(_ string, _ ...string) error
RemSet method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) RemSorted ¶
func (NoDatabase) RemSorted(_ ...SetMember) error
RemSorted method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) RemSortedByScore ¶
func (NoDatabase) RemSortedByScore(_ string, _, _ float64) error
RemSortedByScore method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) Scan ¶
func (NoDatabase) Scan(_ func(string) error) error
func (NoDatabase) Set ¶
func (NoDatabase) Set(_ ...Value) error
func (NoDatabase) SetSet ¶
func (NoDatabase) SetSet(_ string, _ ...string) error
SetSet method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) SetSorted ¶
func (NoDatabase) SetSorted(_ string, _ []Scored) error
SetSorted method of NoDatabase returns ErrNoDatabase.
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis cache storage.
func (*Redis) AddSet ¶
AddSet adds members to a set in Redis.
func (*Redis) AddSorted ¶
AddSorted add scores to sorted set.
func (*Redis) GetSet ¶
GetSet returns members of a set from Redis.
func (*Redis) GetSorted ¶
GetSorted get scores from sorted set.
func (*Redis) GetSortedByScore ¶
func (*Redis) RemSet ¶
RemSet removes members from a set in Redis.
func (*Redis) RemSorted ¶
RemSorted method of NoDatabase returns ErrNoDatabase.
func (*Redis) RemSortedByScore ¶
func (*Redis) SetSet ¶
SetSet overrides a set with members in Redis.
type ReturnValue ¶
type ReturnValue struct {
// contains filtered or unexported fields
}
func (*ReturnValue) Integer ¶
func (r *ReturnValue) Integer() (int, error)
func (*ReturnValue) String ¶
func (r *ReturnValue) String() (string, error)
func (*ReturnValue) Time ¶
func (r *ReturnValue) Time() (time.Time, error)
type SQLDatabase ¶
type SQLDatabase struct {
// contains filtered or unexported fields
}
func (*SQLDatabase) AddSet ¶
func (db *SQLDatabase) AddSet(key string, members ...string) error
func (*SQLDatabase) AddSorted ¶
func (db *SQLDatabase) AddSorted(sortedSets ...SortedSet) error
func (*SQLDatabase) Close ¶
func (db *SQLDatabase) Close() error
func (*SQLDatabase) Delete ¶
func (db *SQLDatabase) Delete(name string) error
func (*SQLDatabase) Get ¶
func (db *SQLDatabase) Get(name string) *ReturnValue
func (*SQLDatabase) GetSet ¶
func (db *SQLDatabase) GetSet(key string) ([]string, error)
func (*SQLDatabase) GetSorted ¶
func (db *SQLDatabase) GetSorted(key string, begin, end int) ([]Scored, error)
func (*SQLDatabase) GetSortedByScore ¶
func (db *SQLDatabase) GetSortedByScore(key string, begin, end float64) ([]Scored, error)
func (*SQLDatabase) Init ¶
func (db *SQLDatabase) Init() error
func (*SQLDatabase) RemSet ¶
func (db *SQLDatabase) RemSet(key string, members ...string) error
func (*SQLDatabase) RemSorted ¶
func (db *SQLDatabase) RemSorted(members ...SetMember) error
func (*SQLDatabase) RemSortedByScore ¶
func (db *SQLDatabase) RemSortedByScore(key string, begin, end float64) error
func (*SQLDatabase) Scan ¶
func (db *SQLDatabase) Scan(work func(string) error) error
func (*SQLDatabase) Set ¶
func (db *SQLDatabase) Set(values ...Value) error
func (*SQLDatabase) SetSet ¶
func (db *SQLDatabase) SetSet(key string, members ...string) error
func (*SQLDatabase) SetSorted ¶
func (db *SQLDatabase) SetSorted(key string, scores []Scored) error
type SQLSet ¶
type SQLSortedSet ¶
type SQLSortedSet struct { Name string `gorm:"type:varchar(256);primaryKey;index:name"` Member string `gorm:"type:varchar(256);primaryKey"` Score float64 `gorm:"type:double precision;not null;index:name"` }
func (*SQLSortedSet) TableName ¶
func (*SQLSortedSet) TableName() string
type SQLValue ¶
type Scored ¶
Scored associate a id with a score.
type SetMember ¶
type SetMember struct {
// contains filtered or unexported fields
}
type SortedSet ¶
type SortedSet struct {
// contains filtered or unexported fields
}