Documentation ¶
Index ¶
- Constants
- Variables
- func RemoveScores(items []Scored) []string
- type Database
- type NoDatabase
- func (NoDatabase) AppendScores(_, _ string, _ ...Scored) error
- func (NoDatabase) ClearScores(_, _ string) error
- func (NoDatabase) Close() error
- func (NoDatabase) GetInt(_, _ string) (int, error)
- func (NoDatabase) GetScores(_, _ string, _, _ int) ([]Scored, error)
- func (NoDatabase) GetString(_, _ string) (string, error)
- func (NoDatabase) GetTime(_, _ string) (time.Time, error)
- func (NoDatabase) IncrInt(_, _ string) error
- func (NoDatabase) SetInt(_, _ string, _ int) error
- func (NoDatabase) SetScores(_, _ string, _ []Scored) error
- func (NoDatabase) SetString(_, _, _ string) error
- func (NoDatabase) SetTime(_, _ string, _ time.Time) error
- type Redis
- func (r *Redis) AppendScores(prefix, name string, items ...Scored) error
- func (r *Redis) ClearScores(prefix, name string) error
- func (r *Redis) Close() error
- func (r *Redis) GetInt(prefix, name string) (int, error)
- func (r *Redis) GetScores(prefix, name string, begin, end int) ([]Scored, error)
- func (r *Redis) GetString(prefix, name string) (string, error)
- func (r *Redis) GetTime(prefix, name string) (time.Time, error)
- func (r *Redis) IncrInt(prefix, name string) error
- func (r *Redis) SetInt(prefix, name string, val int) error
- func (r *Redis) SetScores(prefix, name string, items []Scored) error
- func (r *Redis) SetString(prefix, name, val string) error
- func (r *Redis) SetTime(prefix, name string, val time.Time) error
- type Scored
Constants ¶
const ( IgnoreItems = "ignore_items" ItemNeighbors = "item_neighbors" UserNeighbors = "user_neighbors" CollaborativeRecommend = "collaborative_recommend" CTRRecommend = "ctr_recommend" PopularItems = "popular_items" LatestItems = "latest_items" 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" LastFitRankingModelTime = "last_fit_match_model_time" LastRankingModelVersion = "latest_match_model_version" )
Variables ¶
var ( SetScoresSeconds = promauto.NewHistogram(prometheus.HistogramOpts{ Namespace: "gorse", Subsystem: "cache", Name: "cache_set_scores_seconds", }) GetScoresSeconds = promauto.NewHistogram(prometheus.HistogramOpts{ Namespace: "gorse", Subsystem: "cache", Name: "cache_get_scores_seconds", }) ClearScoresSeconds = promauto.NewHistogram(prometheus.HistogramOpts{ Namespace: "gorse", Subsystem: "cache", Name: "cache_clear_scores_seconds", }) AppendScoresSeconds = promauto.NewHistogram(prometheus.HistogramOpts{ Namespace: "gorse", Subsystem: "cache", Name: "cache_append_scores_seconds", }) SetScoresTimes = promauto.NewCounter(prometheus.CounterOpts{ Namespace: "gorse", Subsystem: "cache", Name: "cache_set_scores_times", }) GetScoresTimes = promauto.NewCounter(prometheus.CounterOpts{ Namespace: "gorse", Subsystem: "cache", Name: "cache_get_scores_times", }) ClearScoresTimes = promauto.NewCounter(prometheus.CounterOpts{ Namespace: "gorse", Subsystem: "cache", Name: "cache_clear_scores_times", }) AppendScoresTimes = promauto.NewCounter(prometheus.CounterOpts{ Namespace: "gorse", Subsystem: "cache", Name: "cache_append_scores_times", }) )
var ErrNoDatabase = fmt.Errorf("no database specified")
var ErrObjectNotExist = fmt.Errorf("object not exists")
Functions ¶
func RemoveScores ¶
RemoveScores resolve items for a slice of ScoredItems.
Types ¶
type Database ¶
type Database interface { Close() error SetScores(prefix, name string, items []Scored) error GetScores(prefix, name string, begin int, end int) ([]Scored, error) ClearScores(prefix, name string) error AppendScores(prefix, name string, items ...Scored) error GetString(prefix, name string) (string, error) SetString(prefix, name string, val string) error GetTime(prefix, name string) (time.Time, error) SetTime(prefix, name string, val time.Time) error GetInt(prefix, name string) (int, error) SetInt(prefix, name string, val int) error IncrInt(prefix, name string) error }
Database is the common interface for cache store.
type NoDatabase ¶
type NoDatabase struct{}
NoDatabase means no database used for cache.
func (NoDatabase) AppendScores ¶ added in v0.2.7
func (NoDatabase) AppendScores(_, _ string, _ ...Scored) error
AppendScores method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) ClearScores ¶ added in v0.2.7
func (NoDatabase) ClearScores(_, _ string) error
ClearScores method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) Close ¶
func (NoDatabase) Close() error
Close method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetInt ¶
func (NoDatabase) GetInt(_, _ string) (int, error)
GetInt method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetScores ¶
func (NoDatabase) GetScores(_, _ string, _, _ int) ([]Scored, error)
GetScores method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetString ¶
func (NoDatabase) GetString(_, _ string) (string, error)
GetString method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetTime ¶
func (NoDatabase) GetTime(_, _ string) (time.Time, error)
GetTime method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) IncrInt ¶
func (NoDatabase) IncrInt(_, _ string) error
IncrInt method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) SetInt ¶
func (NoDatabase) SetInt(_, _ string, _ int) error
SetInt method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) SetScores ¶
func (NoDatabase) SetScores(_, _ string, _ []Scored) error
SetScores method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) SetString ¶
func (NoDatabase) SetString(_, _, _ string) error
SetString method of NoDatabase returns ErrNoDatabase.
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis cache storage.
func (*Redis) AppendScores ¶ added in v0.2.7
AppendScores appends a list of scored items to Redis.
func (*Redis) ClearScores ¶ added in v0.2.7
ClearScores clears a list of scored items in Redis.