Documentation
¶
Index ¶
- func CacheClear()
- func CacheDelete(hash string)
- func CacheGetQueries() int64
- func CacheLookup(hash string) []byte
- func CacheStore(hash string, data []byte)
- func CacheStoreWithTTL(hash string, data []byte, ttl time.Duration)
- func CalculateHash(c *fiber.Ctx) string
- func EnableCache(cfg *CacheConfig)
- func GetCacheMaxMemorySize() int64
- func GetCacheMemoryUsage() int64
- func IsCacheInitialized() bool
- func ShouldUseRedisCache(cfg *CacheConfig) bool
- type CacheClient
- type CacheConfig
- type CacheStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheClear ¶ added in v0.18.7
func CacheClear()
func CacheDelete ¶ added in v0.18.7
func CacheDelete(hash string)
func CacheGetQueries ¶ added in v0.18.7
func CacheGetQueries() int64
func CacheLookup ¶ added in v0.18.7
func CacheStore ¶ added in v0.18.7
func CacheStoreWithTTL ¶ added in v0.18.7
func CalculateHash ¶ added in v0.18.7
CalculateHash generates an MD5 hash from the request body. For GraphQL requests, this includes both the query and variables, ensuring that identical queries with different variables are cached separately.
Example GraphQL request body:
{
"query": "query GetUser($id: ID!) { user(id: $id) { name } }",
"variables": { "id": "123" }
}
Different variable values will produce different cache keys.
func EnableCache ¶ added in v0.18.7
func EnableCache(cfg *CacheConfig)
func GetCacheMaxMemorySize ¶ added in v0.29.1
func GetCacheMaxMemorySize() int64
GetCacheMaxMemorySize returns the maximum memory size allowed for the cache in bytes
func GetCacheMemoryUsage ¶ added in v0.29.1
func GetCacheMemoryUsage() int64
GetCacheMemoryUsage returns the current memory usage of the cache in bytes
func IsCacheInitialized ¶ added in v0.21.82
func IsCacheInitialized() bool
func ShouldUseRedisCache ¶ added in v0.18.7
func ShouldUseRedisCache(cfg *CacheConfig) bool
Types ¶
type CacheClient ¶ added in v0.18.7
type CacheClient interface {
Set(key string, value []byte, ttl time.Duration)
Get(key string) ([]byte, bool)
Delete(key string)
Clear()
CountQueries() int64
// Memory usage reporting methods
GetMemoryUsage() int64 // Returns current memory usage in bytes
GetMaxMemorySize() int64 // Returns max memory size in bytes
}
type CacheConfig ¶ added in v0.18.7
type CacheConfig struct {
Logger *libpack_logger.Logger
Client CacheClient
Redis struct {
URL string `json:"url"`
Password string `json:"password"`
DB int `json:"db"`
Enable bool `json:"enable"`
}
Memory struct {
MaxMemorySize int64 `json:"max_memory_size"` // Maximum memory size in bytes
MaxEntries int64 `json:"max_entries"` // Maximum number of entries
}
TTL int `json:"ttl"`
}
type CacheStats ¶ added in v0.15.4
type CacheStats struct {
CachedQueries int64 `json:"cached_queries"`
CacheHits int64 `json:"cache_hits"`
CacheMisses int64 `json:"cache_misses"`
}
func GetCacheStats ¶ added in v0.18.7
func GetCacheStats() *CacheStats
Click to show internal directories.
Click to hide internal directories.