Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Get = func(key string) ([]string, bool) { log.Debug("get value from cache") header, exists := SessionCache.Get(key) var cachedDatasets []string if header != nil { cachedDatasets = header.(DatasetCache).Datasets } else { cachedDatasets = nil } log.Debugf("cache response, exists=%t, datasets=%s", exists, cachedDatasets) return cachedDatasets, exists }
Get returns a value from cache at key
var NewSessionKey = func() string { log.Debug("generating new session key") // Generate a new key until one is generated, which doesn't already exist var sessionKey string exists := true for exists { key := uuid.New().String() sessionKey = key _, exists = Get(key) } log.Debug("new session key generated") return sessionKey }
NewSessionKey generates a session key used for storing dataset permissions, and checks that it doesn't already exist
var SessionCache *ristretto.Cache
SessionCache stores dataset permission lists
Functions ¶
func InitialiseSessionCache ¶
InitialiseSessionCache creates a cache manager that stores keys and values in memory
Types ¶
type DatasetCache ¶
type DatasetCache struct {
Datasets []string
}
DatasetCache stores the dataset permissions and information whether this information has already been checked or not. This information can then be used to skip the time-costly authentication middleware DatasetCache==nil, session doesn't exist DatasetCache.Datasets==nil, session exists, user has no permissions (this case is not used in middleware.go) DatasetCache.Datasets==[]string{}, session exists, user has permissions