Skip to content
Snippets Groups Projects
Commit b333d47a authored by Travis Ralston's avatar Travis Ralston
Browse files

Deprecate in-memory cache, preferring redis

parent f94521bb
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased]
### Deprecation notices
In a future version (likely the next), the in-memory cache support will be removed. Instead, please use the Redis
caching that is now supported properly by this release, or disable caching if not applicable for your deployment.
### Changed
* Support the Redis config at the root level of the config, promoting it to a proper feature.
## [1.2.7] - April 19th, 2021
### Security advisories
......
......@@ -15,6 +15,7 @@ type MainRepoConfig struct {
Federation FederationConfig `yaml:"federation"`
Plugins []PluginConfig `yaml:"plugins,flow"`
Sentry SentryConfig `yaml:"sentry"`
Redis RedisConfig `yaml:"redis"`
}
func NewDefaultMainConfig() MainRepoConfig {
......@@ -136,5 +137,9 @@ func NewDefaultMainConfig() MainRepoConfig {
Environment: "",
Debug: false,
},
Redis: RedisConfig{
Enabled: false,
Shards: []RedisShardConfig{},
},
}
}
......@@ -111,16 +111,6 @@ type IPFSDaemonConfig struct {
RepoPath string `yaml:"repoPath"`
}
type RedisConfig struct {
Enabled bool `yaml:"enabled"`
Shards []RedisShardConfig `yaml:"shards,flow"`
}
type RedisShardConfig struct {
Name string `yaml:"name"`
Address string `yaml:"addr"`
}
type AccessTokenConfig struct {
MaxCacheTimeSeconds int `yaml:"maxCacheTimeSeconds"`
UseAppservices bool `yaml:"useLocalAppserviceConfig"`
......
......@@ -88,3 +88,13 @@ type SentryConfig struct {
Environment string `yaml:"environment"`
Debug bool `yaml:"debug"`
}
type RedisConfig struct {
Enabled bool `yaml:"enabled"`
Shards []RedisShardConfig `yaml:"shards,flow"`
}
type RedisShardConfig struct {
Name string `yaml:"name"`
Address string `yaml:"addr"`
}
\ No newline at end of file
package internal_cache
import (
"github.com/getsentry/sentry-go"
"sync"
"github.com/sirupsen/logrus"
......@@ -16,14 +17,27 @@ func Get() ContentCache {
}
lock.Do(func() {
if config.Get().Features.Redis.Enabled {
if config.Get().Redis.Enabled {
logrus.Info("Setting up Redis cache")
instance = NewRedisCache()
} else if config.Get().Features.Redis.Enabled {
logrus.Info("Setting up Redis cache")
warnMsg := "Your configuration uses a legacy approach for enabling Redis support. Please move this to the root config or visit #media-repo:t2bot.io for assistance."
logrus.Warn(warnMsg)
sentry.CaptureMessage(warnMsg)
instance = NewRedisCache()
} else if !config.Get().Downloads.Cache.Enabled {
logrus.Warn("Cache is disabled - setting up a dummy instance")
instance = NewNoopCache()
} else {
logrus.Info("Setting up in-memory cache")
warnMsg := "The built-in cache mechanism is being removed in a future version. Please set up Redis as a cache mechanism."
logrus.Warn(warnMsg)
sentry.CaptureMessage(warnMsg)
instance = NewMemoryCache()
}
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment