api-server: github.com/DevMine/api-server/cache Index | Files

package cache

import "github.com/DevMine/api-server/cache"

Package cache provides caching. All data that can be loaded once into memory is dealt with in this package. To use it, a call to LoadCache() shall be made once at the start of the application. After the data is loaded into memory, it can be accessed with the getters functions.

Index

Package Files

api.go cache.go score.go

func GetFeatures Uses

func GetFeatures() []model.Feature

GetFeatures returns a slice containing all features.

func GetFeaturesNames Uses

func GetFeaturesNames() map[string]struct{}

GetFeaturesNames returns a map of features names. It can be used to check in O(1) if a feature exists by providing its name as a key to the map.

func GetScoresMatrix Uses

func GetScoresMatrix() *mx.Sparse

GetScoresMatrix returns the scores matrix from cache. Each row of the matrix corresponds to a user whereas each column corresponds to a feature. The scores matrix is closely related to the users vector. Row 'i' of the scores matrix corresponds to the scores for each feature for the user at row 'i' in the users vector.

func GetStats Uses

func GetStats() model.Stats

GetStats provides database statistics.

func GetUsersVector Uses

func GetUsersVector() []model.User

GetUsersVector returns the vector of users from cache. Important: the vector is sorted, matching the rows of the scores matrix. In other words, user at position 'i' in the slice corresponds as the scores for each feature at row 'i' of the scores matrix.

func LoadCache Uses

func LoadCache(db *sql.DB) error

LoadCache loads all cacheable data into memory.

Package cache imports 6 packages (graph) and is imported by 4 packages. Updated 2016-08-02. Refresh now. Tools for package owners.