features

package
v0.22.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package features handles feature entitlements

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCache

func WithCache(ctx context.Context, c *Cache) context.Context

WithCache stores the feature cache on the context for downstream use.

Types

type Cache

type Cache struct {
	Redis *redis.Client
	TTL   time.Duration
}

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

func CacheFromContext(ctx context.Context) (*Cache, bool)

CacheFromContext retrieves the feature cache from context if present.

func NewCache

func NewCache(r *redis.Client, ttl time.Duration) *Cache

NewCache returns a Cache using the provided redis client.

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, orgID string) ([]string, error)

Get returns the cached features for an organization or nil when absent.

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, orgID string, feats []string) error

Set stores the feature list for an organization.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL