2025-01-04 01:28:54 +05:30
|
|
|
package cache
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
2025-03-20 21:01:41 +05:30
|
|
|
"github.com/SigNoz/signoz/pkg/factory"
|
2025-01-04 01:28:54 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Memory struct {
|
|
|
|
|
TTL time.Duration `mapstructure:"ttl"`
|
2025-05-03 18:30:07 +05:30
|
|
|
CleanupInterval time.Duration `mapstructure:"cleanup_interval"`
|
2025-01-04 01:28:54 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Redis struct {
|
|
|
|
|
Host string `mapstructure:"host"`
|
|
|
|
|
Port int `mapstructure:"port"`
|
|
|
|
|
Password string `mapstructure:"password"`
|
|
|
|
|
DB int `mapstructure:"db"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
|
Provider string `mapstructure:"provider"`
|
|
|
|
|
Memory Memory `mapstructure:"memory"`
|
|
|
|
|
Redis Redis `mapstructure:"redis"`
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-20 17:45:33 +05:30
|
|
|
func NewConfigFactory() factory.ConfigFactory {
|
|
|
|
|
return factory.NewConfigFactory(factory.MustNewName("cache"), newConfig)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newConfig() factory.Config {
|
2025-01-04 01:28:54 +05:30
|
|
|
return &Config{
|
|
|
|
|
Provider: "memory",
|
|
|
|
|
Memory: Memory{
|
2025-05-22 17:16:09 +05:30
|
|
|
TTL: time.Hour * 168,
|
|
|
|
|
CleanupInterval: 10 * time.Minute,
|
2025-01-04 01:28:54 +05:30
|
|
|
},
|
|
|
|
|
Redis: Redis{
|
|
|
|
|
Host: "localhost",
|
|
|
|
|
Port: 6379,
|
|
|
|
|
Password: "",
|
|
|
|
|
DB: 0,
|
|
|
|
|
},
|
|
|
|
|
}
|
2025-01-20 17:45:33 +05:30
|
|
|
|
2025-01-04 01:28:54 +05:30
|
|
|
}
|
|
|
|
|
|
2025-01-20 17:45:33 +05:30
|
|
|
func (c Config) Validate() error {
|
2025-01-04 01:28:54 +05:30
|
|
|
return nil
|
|
|
|
|
}
|