utils

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheUserPermissions

func CacheUserPermissions(userID uint, method string, data interface{}, ttl time.Duration)

CacheUserPermissions caches user permission results with a standardized key format

func DeserializeCacheData

func DeserializeCacheData(bytes []byte, target interface{}) error

DeserializeCacheData converts JSON back to data

func GetCachedUserPermissions

func GetCachedUserPermissions(userID uint, method string) (interface{}, bool)

GetCachedUserPermissions retrieves cached user permission results

func InvalidateUserCache

func InvalidateUserCache(userID uint)

InvalidateUserCache invalidates all cached permissions for a user

func InvalidateUserGroupCache

func InvalidateUserGroupCache(groupID uint, userIDs []uint)

InvalidateUserGroupCache invalidates cache for all users affected by group changes

func SerializeCacheData

func SerializeCacheData(data interface{}) []byte

SerializeCacheData converts data to JSON for consistent caching

Types

type CacheEntry

type CacheEntry struct {
	Data      interface{}
	ExpiresAt time.Time
}

CacheEntry represents a cached item with expiry

type MemoryCache

type MemoryCache struct {
	// contains filtered or unexported fields
}

MemoryCache is a simple in-memory cache with TTL support

func GetCache

func GetCache() *MemoryCache

GetCache returns the global cache instance (singleton)

func (*MemoryCache) Clear

func (c *MemoryCache) Clear()

Clear removes all entries from the cache

func (*MemoryCache) Delete

func (c *MemoryCache) Delete(key string)

Delete removes a value from the cache

func (*MemoryCache) DeletePattern

func (c *MemoryCache) DeletePattern(pattern string)

DeletePattern removes all keys matching a pattern (prefix)

func (*MemoryCache) Get

func (c *MemoryCache) Get(key string) (interface{}, bool)

Get retrieves a value from the cache

func (*MemoryCache) Set

func (c *MemoryCache) Set(key string, value interface{}, ttl time.Duration)

Set stores a value in the cache with the given TTL

Directories

Path Synopsis
proxy-tests
anthropic command
ollama command
openai command
vertex command

Jump to

Keyboard shortcuts

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