Always enable caches (#28527)

Nowadays, cache will be used on almost everywhere of Gitea and it cannot
be disabled, otherwise some features will become unaviable.

Then I think we can just remove the option for cache enable. That means
cache cannot be disabled.
But of course, we can still use cache configuration to set how should
Gitea use the cache.
This commit is contained in:
Lunny Xiao
2023-12-19 17:29:05 +08:00
repo.diff.committed_by GitHub
repo.diff.parent 4eb2a29910
repo.diff.commit e7cb8da2a8
repo.diff.stats_desc%!(EXTRA int=14, int=31, int=82)

6
modules/cache/cache.go repo.diff.vendored
repo.diff.view_file

@@ -24,11 +24,11 @@ func newCache(cacheConfig setting.Cache) (mc.Cache, error) {
})
}
// NewContext start cache service
func NewContext() error {
// Init start cache service
func Init() error {
var err error
if conn == nil && setting.CacheService.Enabled {
if conn == nil {
if conn, err = newCache(setting.CacheService.Cache); err != nil {
return err
}

4
modules/cache/cache_test.go repo.diff.vendored
repo.diff.view_file

@@ -22,9 +22,9 @@ func createTestCache() {
}
func TestNewContext(t *testing.T) {
assert.NoError(t, NewContext())
assert.NoError(t, Init())
setting.CacheService.Cache = setting.Cache{Enabled: true, Adapter: "redis", Conn: "some random string"}
setting.CacheService.Cache = setting.Cache{Adapter: "redis", Conn: "some random string"}
con, err := newCache(setting.Cache{
Adapter: "rand",
Conn: "false conf",