Documentation
¶
Overview ¶
Package permissioncache handles permissioncache for things like features
Index ¶
- func SetCacheContext(c echo.Context, redisClient *redis.Client, opts ...CacheOptions)
- func WithCache(ctx context.Context, c *Cache) context.Context
- type Cache
- func (c *Cache) GetFeatures(ctx context.Context, orgID string) ([]models.OrgModule, error)
- func (c *Cache) GetRoles(ctx context.Context, subjectID, orgID string) ([]string, error)
- func (c *Cache) GetUserOrgs(ctx context.Context, subjectID string) ([]string, error)
- func (c *Cache) HasOrgAccess(ctx context.Context, subjectID, orgID string) (bool, error)
- func (c *Cache) HasRole(ctx context.Context, subjectID, orgID string, role string) (bool, error)
- func (c *Cache) SetFeatures(ctx context.Context, orgID string, values []models.OrgModule) error
- func (c *Cache) SetRole(ctx context.Context, subjectID, orgID string, value string) error
- type CacheOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetCacheContext ¶
func SetCacheContext(c echo.Context, redisClient *redis.Client, opts ...CacheOptions)
SetCacheContext sets the cache context in the echo context, defaults to a ttl of 5 minutes if not specified
Types ¶
type Cache ¶
Cache stores enabled feature sets in Redis keyed by organization ID. It reuses the same Redis instance as the session store but keeps feature data separate from user session values so entries can expire independently.
func CacheFromContext ¶
CacheFromContext retrieves the feature cache from context if present.
func NewCache ¶
func NewCache(r *redis.Client, opts ...CacheOptions) *Cache
NewCache returns a Cache using the provided redis client.
func (*Cache) GetFeatures ¶
GetFeatures retrieves the feature list for an organization.
func (*Cache) GetUserOrgs ¶
GetUserOrgs retrieves the organizations a user belongs to.
func (*Cache) HasOrgAccess ¶
func (*Cache) SetFeatures ¶
SetFeatures stores the feature list for an organization.
type CacheOptions ¶
type CacheOptions func(*Cache)
CacheOptions is a functional option type for configuring the Cache.
func WithCacheTTL ¶
func WithCacheTTL(ttl time.Duration) CacheOptions
WithCacheTTL sets the time-to-live for cache entries. If ttl is zero, the default TTL will be used.