feat: add hook system, QR code login, and layered cache
- Implement extensible hook system for content moderation with builtin and AI-powered moderation hooks - Add QR code login feature with SSE for real-time status updates and scan/confirm/cancel workflow - Introduce layered cache with local LRU + Redis backend for improved read performance - Refactor post and comment services to use hook-based moderation instead of direct AI service calls - Add local cache configuration options (size, buckets, ttl)
This commit is contained in:
@@ -72,6 +72,10 @@ func Load(configPath string) (*Config, error) {
|
||||
viper.SetDefault("cache.modules.conversation_ttl", 60)
|
||||
viper.SetDefault("cache.modules.unread_count_ttl", 30)
|
||||
viper.SetDefault("cache.modules.group_members_ttl", 120)
|
||||
viper.SetDefault("cache.local.enabled", true)
|
||||
viper.SetDefault("cache.local.size", 10000)
|
||||
viper.SetDefault("cache.local.buckets", 0)
|
||||
viper.SetDefault("cache.local.default_ttl", 300)
|
||||
viper.SetDefault("jwt.secret", "your-jwt-secret-key-change-in-production")
|
||||
viper.SetDefault("jwt.access_token_expire", 86400)
|
||||
viper.SetDefault("jwt.refresh_token_expire", 604800)
|
||||
|
||||
@@ -17,13 +17,22 @@ type RedisConfig struct {
|
||||
|
||||
// CacheConfig 缓存配置
|
||||
type CacheConfig struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
KeyPrefix string `mapstructure:"key_prefix"`
|
||||
DefaultTTL int `mapstructure:"default_ttl"`
|
||||
NullTTL int `mapstructure:"null_ttl"`
|
||||
JitterRatio float64 `mapstructure:"jitter_ratio"`
|
||||
DisableFlushDB bool `mapstructure:"disable_flushdb"`
|
||||
Modules CacheModuleTTL `mapstructure:"modules"`
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
KeyPrefix string `mapstructure:"key_prefix"`
|
||||
DefaultTTL int `mapstructure:"default_ttl"`
|
||||
NullTTL int `mapstructure:"null_ttl"`
|
||||
JitterRatio float64 `mapstructure:"jitter_ratio"`
|
||||
DisableFlushDB bool `mapstructure:"disable_flushdb"`
|
||||
Modules CacheModuleTTL `mapstructure:"modules"`
|
||||
Local LocalCacheConfig `mapstructure:"local"`
|
||||
}
|
||||
|
||||
// LocalCacheConfig 本地缓存配置
|
||||
type LocalCacheConfig struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Size int `mapstructure:"size"`
|
||||
Buckets int `mapstructure:"buckets"`
|
||||
DefaultTTL int `mapstructure:"default_ttl"`
|
||||
}
|
||||
|
||||
// CacheModuleTTL 缓存模块 TTL 配置
|
||||
|
||||
Reference in New Issue
Block a user