utils

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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