Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertDocumentsToValues(documents []Score) []string
- func Key(keys ...string) string
- func Register(prefixes []string, creator Creator)
- func SortDocuments(documents []Score)
- type Creator
- type Database
- type Message
- type MongoDB
- func (m MongoDB) AddScores(ctx context.Context, collection, subset string, documents []Score) error
- func (m MongoDB) AddTimeSeriesPoints(ctx context.Context, points []TimeSeriesPoint) error
- func (m MongoDB) Close() error
- func (m MongoDB) Delete(ctx context.Context, name string) error
- func (m MongoDB) DeleteScores(ctx context.Context, collections []string, condition ScoreCondition) error
- func (m MongoDB) Get(ctx context.Context, name string) *ReturnValue
- func (m MongoDB) GetTimeSeriesPoints(ctx context.Context, name string, begin, end time.Time, duration time.Duration) ([]TimeSeriesPoint, error)
- func (m MongoDB) Init() error
- func (m MongoDB) Ping() error
- func (m MongoDB) Pop(ctx context.Context, name string) (string, error)
- func (m MongoDB) Purge() error
- func (m MongoDB) Push(ctx context.Context, name, value string) error
- func (m MongoDB) Remain(ctx context.Context, name string) (int64, error)
- func (m MongoDB) Scan(work func(string) error) error
- func (m MongoDB) ScanScores(ctx context.Context, ...) error
- func (m MongoDB) SearchScores(ctx context.Context, collection, subset string, query []string, begin, end int) ([]Score, error)
- func (m MongoDB) Set(ctx context.Context, values ...Value) error
- func (m MongoDB) UpdateScores(ctx context.Context, collections []string, subset *string, id string, ...) error
- type NoDatabase
- func (NoDatabase) AddScores(_ context.Context, _, _ string, _ []Score) error
- func (NoDatabase) AddTimeSeriesPoints(_ context.Context, _ []TimeSeriesPoint) error
- func (NoDatabase) Close() error
- func (NoDatabase) Delete(_ context.Context, _ string) error
- func (NoDatabase) DeleteScores(_ context.Context, _ []string, _ ScoreCondition) error
- func (NoDatabase) Get(_ context.Context, _ string) *ReturnValue
- func (NoDatabase) GetTimeSeriesPoints(_ context.Context, _ string, _, _ time.Time, _ time.Duration) ([]TimeSeriesPoint, error)
- func (NoDatabase) Init() error
- func (NoDatabase) Ping() error
- func (NoDatabase) Pop(_ context.Context, _ string) (string, error)
- func (NoDatabase) Purge() error
- func (NoDatabase) Push(_ context.Context, _, _ string) error
- func (NoDatabase) Remain(_ context.Context, _ string) (int64, error)
- func (NoDatabase) Scan(_ func(string) error) error
- func (NoDatabase) ScanScores(context.Context, ...) error
- func (NoDatabase) SearchScores(_ context.Context, _, _ string, _ []string, _, _ int) ([]Score, error)
- func (NoDatabase) Set(_ context.Context, _ ...Value) error
- func (NoDatabase) UpdateScores(context.Context, []string, *string, string, ScorePatch) error
- type PostgresDocument
- type ProxyClient
- func (p ProxyClient) AddScores(ctx context.Context, collection, subset string, documents []Score) error
- func (p ProxyClient) AddTimeSeriesPoints(ctx context.Context, points []TimeSeriesPoint) error
- func (p ProxyClient) Close() error
- func (p ProxyClient) Delete(ctx context.Context, name string) error
- func (p ProxyClient) DeleteScores(ctx context.Context, collection []string, condition ScoreCondition) error
- func (p ProxyClient) Get(ctx context.Context, name string) *ReturnValue
- func (p ProxyClient) GetTimeSeriesPoints(ctx context.Context, name string, begin, end time.Time, duration time.Duration) ([]TimeSeriesPoint, error)
- func (p ProxyClient) Init() error
- func (p ProxyClient) Ping() error
- func (p ProxyClient) Pop(ctx context.Context, name string) (string, error)
- func (p ProxyClient) Purge() error
- func (p ProxyClient) Push(ctx context.Context, name, value string) error
- func (p ProxyClient) Remain(ctx context.Context, name string) (int64, error)
- func (p ProxyClient) Scan(_ func(string) error) error
- func (p ProxyClient) ScanScores(ctx context.Context, ...) error
- func (p ProxyClient) SearchScores(ctx context.Context, collection, subset string, query []string, begin, end int) ([]Score, error)
- func (p ProxyClient) Set(ctx context.Context, values ...Value) error
- func (p ProxyClient) UpdateScores(ctx context.Context, collection []string, subset *string, id string, ...) error
- type ProxyServer
- func (p *ProxyServer) AddScores(ctx context.Context, request *protocol.AddScoresRequest) (*protocol.AddScoresResponse, error)
- func (p *ProxyServer) AddTimeSeriesPoints(ctx context.Context, request *protocol.AddTimeSeriesPointsRequest) (*protocol.AddTimeSeriesPointsResponse, error)
- func (p *ProxyServer) Delete(ctx context.Context, request *protocol.DeleteRequest) (*protocol.DeleteResponse, error)
- func (p *ProxyServer) DeleteScores(ctx context.Context, request *protocol.DeleteScoresRequest) (*protocol.DeleteScoresResponse, error)
- func (p *ProxyServer) Get(ctx context.Context, request *protocol.GetRequest) (*protocol.GetResponse, error)
- func (p *ProxyServer) GetTimeSeriesPoints(ctx context.Context, request *protocol.GetTimeSeriesPointsRequest) (*protocol.GetTimeSeriesPointsResponse, error)
- func (p *ProxyServer) Ping(context.Context, *protocol.PingRequest) (*protocol.PingResponse, error)
- func (p *ProxyServer) Pop(ctx context.Context, request *protocol.PopRequest) (*protocol.PopResponse, error)
- func (p *ProxyServer) Push(ctx context.Context, request *protocol.PushRequest) (*protocol.PushResponse, error)
- func (p *ProxyServer) Remain(ctx context.Context, request *protocol.RemainRequest) (*protocol.RemainResponse, error)
- func (p *ProxyServer) ScanScores(request *protocol.ScanScoresRequest, ...) error
- func (p *ProxyServer) SearchScores(ctx context.Context, request *protocol.SearchScoresRequest) (*protocol.SearchScoresResponse, error)
- func (p *ProxyServer) Serve(lis net.Listener) error
- func (p *ProxyServer) Set(ctx context.Context, request *protocol.SetRequest) (*protocol.SetResponse, error)
- func (p *ProxyServer) Stop()
- func (p *ProxyServer) UpdateScores(ctx context.Context, request *protocol.UpdateScoresRequest) (*protocol.UpdateScoresResponse, error)
- type Redis
- func (r *Redis) AddScores(ctx context.Context, collection, subset string, documents []Score) error
- func (r *Redis) AddTimeSeriesPoints(ctx context.Context, points []TimeSeriesPoint) error
- func (r *Redis) Close() error
- func (r *Redis) Delete(ctx context.Context, key string) error
- func (r *Redis) DeleteScores(ctx context.Context, collections []string, condition ScoreCondition) error
- func (r *Redis) Get(ctx context.Context, key string) *ReturnValue
- func (r *Redis) GetTimeSeriesPoints(ctx context.Context, name string, begin, end time.Time, duration time.Duration) ([]TimeSeriesPoint, error)
- func (r *Redis) Init() error
- func (r *Redis) Ping() error
- func (r *Redis) Pop(ctx context.Context, name string) (string, error)
- func (r *Redis) Purge() error
- func (r *Redis) Push(ctx context.Context, name string, message string) error
- func (r *Redis) Remain(ctx context.Context, name string) (int64, error)
- func (r *Redis) Scan(work func(string) error) error
- func (r *Redis) ScanScores(ctx context.Context, ...) error
- func (r *Redis) SearchScores(ctx context.Context, collection, subset string, query []string, begin, end int) ([]Score, error)
- func (r *Redis) Set(ctx context.Context, values ...Value) error
- func (r *Redis) UpdateScores(ctx context.Context, collections []string, subset *string, id string, ...) error
- type ReturnValue
- type SQLDatabase
- func (db *SQLDatabase) AddScores(ctx context.Context, collection, subset string, documents []Score) error
- func (db *SQLDatabase) AddTimeSeriesPoints(ctx context.Context, points []TimeSeriesPoint) error
- func (db *SQLDatabase) Close() error
- func (db *SQLDatabase) Delete(ctx context.Context, name string) error
- func (db *SQLDatabase) DeleteScores(ctx context.Context, collections []string, condition ScoreCondition) error
- func (db *SQLDatabase) Get(ctx context.Context, name string) *ReturnValue
- func (db *SQLDatabase) GetTimeSeriesPoints(ctx context.Context, name string, begin, end time.Time, duration time.Duration) ([]TimeSeriesPoint, error)
- func (db *SQLDatabase) Init() error
- func (db *SQLDatabase) Ping() error
- func (db *SQLDatabase) Pop(ctx context.Context, name string) (string, error)
- func (db *SQLDatabase) Purge() error
- func (db *SQLDatabase) Push(ctx context.Context, name, value string) error
- func (db *SQLDatabase) Remain(ctx context.Context, name string) (count int64, err error)
- func (db *SQLDatabase) Scan(work func(string) error) error
- func (db *SQLDatabase) ScanScores(ctx context.Context, ...) error
- func (db *SQLDatabase) SearchScores(ctx context.Context, collection, subset string, query []string, begin, end int) ([]Score, error)
- func (db *SQLDatabase) Set(ctx context.Context, values ...Value) error
- func (db *SQLDatabase) UpdateScores(ctx context.Context, collections []string, subset *string, id string, ...) error
- type SQLDocument
- type SQLDriver
- type SQLValue
- type Score
- type ScoreCondition
- type ScorePatch
- type TimeSeriesPoint
- type Value
Constants ¶
View Source
const ( NonPersonalized = "non-personalized" NonPersonalizedDigest = "non-personalized_digest" NonPersonalizedUpdateTime = "non-personalized_update_time" ItemToItem = "item-to-item" ItemToItemDigest = "item-to-item_digest" ItemToItemUpdateTime = "item-to-item_update_time" UserToUser = "user-to-user" UserToUserDigest = "user-to-user_digest" UserToUserUpdateTime = "user-to-user_update_time" CollaborativeFiltering = "collaborative-filtering" CollaborativeFilteringDigest = "collaborative-filtering_digest" CollaborativeFilteringUpdateTime = "collaborative-filtering_update_time" Recommend = "recommend" RecommendDigest = "recommend_digest" RecommendUpdateTime = "recommend_update_time" // 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 // GlobalMeta is global meta information GlobalMeta = "global_meta" DataImported = "data_imported" NumUsers = "num_users" NumItems = "num_items" NumFeedback = "num_feedback" NumPosFeedbacks = "num_pos_feedbacks" NumNegFeedbacks = "num_neg_feedbacks" 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 CFNDCG = "cf_ndcg" CFPrecision = "cf_precision" CFRecall = "cf_recall" CTRPrecision = "ctr_precision" CTRRecall = "ctr_recall" CTRAUC = "ctr_auc" PositiveFeedbackRatio = "positive_feedback_ratio" )
Variables ¶
View Source
var ( ErrObjectNotExist = errors.NotFoundf("object") ErrNoDatabase = errors.NotAssignedf("database") )
View Source
var ItemCache = []string{ NonPersonalized, ItemToItem, Recommend, }
Functions ¶
func SortDocuments ¶
func SortDocuments(documents []Score)
Types ¶
type Database ¶
type Database interface {
Close() error
Ping() error
Init() error
Scan(work func(string) error) error
Purge() error
Set(ctx context.Context, values ...Value) error
Get(ctx context.Context, name string) *ReturnValue
Delete(ctx context.Context, name string) error
Push(ctx context.Context, name, value string) error
Pop(ctx context.Context, name string) (string, error)
Remain(ctx context.Context, name string) (int64, error)
AddScores(ctx context.Context, collection, subset string, documents []Score) error
SearchScores(ctx context.Context, collection, subset string, query []string, begin, end int) ([]Score, error)
DeleteScores(ctx context.Context, collection []string, condition ScoreCondition) error
UpdateScores(ctx context.Context, collections []string, subset *string, id string, patch ScorePatch) error
ScanScores(ctx context.Context, callback func(collection, id, subset string, timestamp time.Time) error) error
AddTimeSeriesPoints(ctx context.Context, points []TimeSeriesPoint) error
GetTimeSeriesPoints(ctx context.Context, name string, begin, end time.Time, duration time.Duration) ([]TimeSeriesPoint, error)
}
Database is the common interface for cache store.
type MongoDB ¶
type MongoDB struct {
storage.TablePrefix
// contains filtered or unexported fields
}
func (MongoDB) AddTimeSeriesPoints ¶
func (m MongoDB) AddTimeSeriesPoints(ctx context.Context, points []TimeSeriesPoint) error
func (MongoDB) DeleteScores ¶
func (MongoDB) GetTimeSeriesPoints ¶
func (MongoDB) ScanScores ¶
func (MongoDB) SearchScores ¶
func (MongoDB) UpdateScores ¶
type NoDatabase ¶
type NoDatabase struct{}
NoDatabase means no database used for cache.
func (NoDatabase) AddTimeSeriesPoints ¶
func (NoDatabase) AddTimeSeriesPoints(_ context.Context, _ []TimeSeriesPoint) error
func (NoDatabase) Close ¶
func (NoDatabase) Close() error
Close method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) Delete ¶
func (NoDatabase) Delete(_ context.Context, _ string) error
Delete method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) DeleteScores ¶
func (NoDatabase) DeleteScores(_ context.Context, _ []string, _ ScoreCondition) error
func (NoDatabase) Get ¶
func (NoDatabase) Get(_ context.Context, _ string) *ReturnValue
Get method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetTimeSeriesPoints ¶
func (NoDatabase) GetTimeSeriesPoints(_ context.Context, _ string, _, _ time.Time, _ time.Duration) ([]TimeSeriesPoint, error)
func (NoDatabase) Init ¶
func (NoDatabase) Init() error
Init method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) Ping ¶
func (NoDatabase) Ping() error
func (NoDatabase) Purge ¶
func (NoDatabase) Purge() error
func (NoDatabase) ScanScores ¶
func (NoDatabase) SearchScores ¶
func (NoDatabase) UpdateScores ¶
func (NoDatabase) UpdateScores(context.Context, []string, *string, string, ScorePatch) error
type PostgresDocument ¶
type ProxyClient ¶
type ProxyClient struct {
protocol.CacheStoreClient
}
func NewProxyClient ¶
func NewProxyClient(conn *grpc.ClientConn) *ProxyClient
func (ProxyClient) AddTimeSeriesPoints ¶
func (p ProxyClient) AddTimeSeriesPoints(ctx context.Context, points []TimeSeriesPoint) error
func (ProxyClient) Close ¶
func (p ProxyClient) Close() error
func (ProxyClient) DeleteScores ¶
func (p ProxyClient) DeleteScores(ctx context.Context, collection []string, condition ScoreCondition) error
func (ProxyClient) Get ¶
func (p ProxyClient) Get(ctx context.Context, name string) *ReturnValue
func (ProxyClient) GetTimeSeriesPoints ¶
func (p ProxyClient) GetTimeSeriesPoints(ctx context.Context, name string, begin, end time.Time, duration time.Duration) ([]TimeSeriesPoint, error)
func (ProxyClient) Init ¶
func (p ProxyClient) Init() error
func (ProxyClient) Ping ¶
func (p ProxyClient) Ping() error
func (ProxyClient) Purge ¶
func (p ProxyClient) Purge() error
func (ProxyClient) ScanScores ¶
func (ProxyClient) SearchScores ¶
func (ProxyClient) UpdateScores ¶
func (p ProxyClient) UpdateScores(ctx context.Context, collection []string, subset *string, id string, patch ScorePatch) error
type ProxyServer ¶
type ProxyServer struct {
protocol.UnimplementedCacheStoreServer
// contains filtered or unexported fields
}
func NewProxyServer ¶
func NewProxyServer(database Database) *ProxyServer
func (*ProxyServer) AddScores ¶
func (p *ProxyServer) AddScores(ctx context.Context, request *protocol.AddScoresRequest) (*protocol.AddScoresResponse, error)
func (*ProxyServer) AddTimeSeriesPoints ¶
func (p *ProxyServer) AddTimeSeriesPoints(ctx context.Context, request *protocol.AddTimeSeriesPointsRequest) (*protocol.AddTimeSeriesPointsResponse, error)
func (*ProxyServer) Delete ¶
func (p *ProxyServer) Delete(ctx context.Context, request *protocol.DeleteRequest) (*protocol.DeleteResponse, error)
func (*ProxyServer) DeleteScores ¶
func (p *ProxyServer) DeleteScores(ctx context.Context, request *protocol.DeleteScoresRequest) (*protocol.DeleteScoresResponse, error)
func (*ProxyServer) Get ¶
func (p *ProxyServer) Get(ctx context.Context, request *protocol.GetRequest) (*protocol.GetResponse, error)
func (*ProxyServer) GetTimeSeriesPoints ¶
func (p *ProxyServer) GetTimeSeriesPoints(ctx context.Context, request *protocol.GetTimeSeriesPointsRequest) (*protocol.GetTimeSeriesPointsResponse, error)
func (*ProxyServer) Ping ¶
func (p *ProxyServer) Ping(context.Context, *protocol.PingRequest) (*protocol.PingResponse, error)
func (*ProxyServer) Pop ¶
func (p *ProxyServer) Pop(ctx context.Context, request *protocol.PopRequest) (*protocol.PopResponse, error)
func (*ProxyServer) Push ¶
func (p *ProxyServer) Push(ctx context.Context, request *protocol.PushRequest) (*protocol.PushResponse, error)
func (*ProxyServer) Remain ¶
func (p *ProxyServer) Remain(ctx context.Context, request *protocol.RemainRequest) (*protocol.RemainResponse, error)
func (*ProxyServer) ScanScores ¶
func (p *ProxyServer) ScanScores(request *protocol.ScanScoresRequest, stream grpc.ServerStreamingServer[protocol.ScanScoresResponse]) error
func (*ProxyServer) SearchScores ¶
func (p *ProxyServer) SearchScores(ctx context.Context, request *protocol.SearchScoresRequest) (*protocol.SearchScoresResponse, error)
func (*ProxyServer) Set ¶
func (p *ProxyServer) Set(ctx context.Context, request *protocol.SetRequest) (*protocol.SetResponse, error)
func (*ProxyServer) Stop ¶
func (p *ProxyServer) Stop()
func (*ProxyServer) UpdateScores ¶
func (p *ProxyServer) UpdateScores(ctx context.Context, request *protocol.UpdateScoresRequest) (*protocol.UpdateScoresResponse, error)
type Redis ¶
type Redis struct {
storage.TablePrefix
// contains filtered or unexported fields
}
Redis cache storage.
func (*Redis) AddTimeSeriesPoints ¶
func (r *Redis) AddTimeSeriesPoints(ctx context.Context, points []TimeSeriesPoint) error
func (*Redis) DeleteScores ¶
func (*Redis) Get ¶
func (r *Redis) Get(ctx context.Context, key string) *ReturnValue
Get returns a value from Redis.
func (*Redis) GetTimeSeriesPoints ¶
func (*Redis) ScanScores ¶
func (*Redis) SearchScores ¶
func (*Redis) UpdateScores ¶
type ReturnValue ¶
type ReturnValue struct {
// contains filtered or unexported fields
}
func (*ReturnValue) Exists ¶
func (r *ReturnValue) Exists() bool
func (*ReturnValue) Integer ¶
func (r *ReturnValue) Integer() (int, error)
func (*ReturnValue) String ¶
func (r *ReturnValue) String() (string, error)
type SQLDatabase ¶
type SQLDatabase struct {
storage.TablePrefix
// contains filtered or unexported fields
}
func (*SQLDatabase) AddTimeSeriesPoints ¶
func (db *SQLDatabase) AddTimeSeriesPoints(ctx context.Context, points []TimeSeriesPoint) error
func (*SQLDatabase) Close ¶
func (db *SQLDatabase) Close() error
func (*SQLDatabase) DeleteScores ¶
func (db *SQLDatabase) DeleteScores(ctx context.Context, collections []string, condition ScoreCondition) error
func (*SQLDatabase) Get ¶
func (db *SQLDatabase) Get(ctx context.Context, name string) *ReturnValue
func (*SQLDatabase) GetTimeSeriesPoints ¶
func (db *SQLDatabase) GetTimeSeriesPoints(ctx context.Context, name string, begin, end time.Time, duration time.Duration) ([]TimeSeriesPoint, error)
func (*SQLDatabase) Init ¶
func (db *SQLDatabase) Init() error
func (*SQLDatabase) Ping ¶
func (db *SQLDatabase) Ping() error
func (*SQLDatabase) Purge ¶
func (db *SQLDatabase) Purge() error
func (*SQLDatabase) Push ¶
func (db *SQLDatabase) Push(ctx context.Context, name, value string) error
func (*SQLDatabase) ScanScores ¶
func (*SQLDatabase) SearchScores ¶
func (*SQLDatabase) UpdateScores ¶
func (db *SQLDatabase) UpdateScores(ctx context.Context, collections []string, subset *string, id string, patch ScorePatch) error
type SQLDocument ¶
type ScoreCondition ¶
func (*ScoreCondition) Check ¶
func (condition *ScoreCondition) Check() error
type ScorePatch ¶
type TimeSeriesPoint ¶
Click to show internal directories.
Click to hide internal directories.