mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 14:26:36 +08:00
416603b616
- Replace db.DB(ctx) with database.DB(ctx) from plugins/infra/database
- Replace db.Redis/db.PrefixedKey/db.GetJSON/db.SetJSON with cachepkg.* from plugins/infra/cache
- Replace pkg/persistence/idgen with pkg/idgen (already exists)
- Replace pkg/persistence/batchwriter with pkg/batchwriter (already exists)
- Replace pkg/persistence/migrator with pkg/migrator (already exists)
- Replace pkg/persistence/logstore with plugins/domain/risk_control/logstore
- Delete defunct pkg/{persistence,cap,message_gateway,push,shared,task}
- Fix vet issues: db alias in domain_test.go, driver_asynq_worker.TaskHandler reference
- Update Makefile architecture guard
- Update docs and skill references
- Update go.mod: gorilla/sessions promotion to direct dependency
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package diskcache
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
|
|
cache "github.com/Rain-kl/Wavelet/plugins/infra/cache"
|
|
"github.com/Rain-kl/Wavelet/pkg/testhelper"
|
|
)
|
|
|
|
func TestDiskCacheReloadConfig(t *testing.T) {
|
|
dbConn, _, cleanup := testhelper.SetupTestEnvironment(t)
|
|
defer cleanup()
|
|
|
|
testDir := "uploads/test_diskcache_reload"
|
|
defer func() { _ = os.RemoveAll(testDir) }()
|
|
_ = os.RemoveAll(testDir)
|
|
|
|
c := New(testDir)
|
|
defer func() { _ = c.Clear() }()
|
|
|
|
// Update DB config values
|
|
dbConn.Table("w_system_configs").Where("key = ?", "disk_cache_max_size_mb").Update("value", "250")
|
|
dbConn.Table("w_system_configs").Where("key = ?", "disk_cache_ttl_minutes").Update("value", "120")
|
|
dbConn.Table("w_system_configs").Where("key = ?", "disk_cache_lru_enabled").Update("value", "false")
|
|
|
|
// Invalidate Redis config cache to force DB reload
|
|
if cache.Redis != nil {
|
|
cache.Redis.Del(context.Background(), cache.PrefixedKey("system_configs"))
|
|
}
|
|
|
|
// Reload config
|
|
c.ReloadConfig(context.Background())
|
|
|
|
status := c.Status()
|
|
if status.MaxSizeMB != 250 {
|
|
t.Errorf("expected MaxSizeMB to be 250, got %d", status.MaxSizeMB)
|
|
}
|
|
if status.TTLMinutes != 120 {
|
|
t.Errorf("expected TTLMinutes to be 120, got %d", status.TTLMinutes)
|
|
}
|
|
if status.LRUEnabled != false {
|
|
t.Errorf("expected LRUEnabled to be false, got %v", status.LRUEnabled)
|
|
}
|
|
}
|