Merge pull request #9888 from kuangp/refactor/redis
refactor(redis): require protocol in connection string
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
---
|
||||
'@backstage/backend-common': minor
|
||||
---
|
||||
|
||||
**BREAKING**: The connection string for `redis` cache store now requires a protocol prefix.
|
||||
|
||||
```diff
|
||||
backend:
|
||||
cache:
|
||||
store: redis
|
||||
- connection: user:pass@cache.example.com:6379
|
||||
+ connection: redis://user:pass@cache.example.com:6379
|
||||
```
|
||||
@@ -310,7 +310,7 @@ backend:
|
||||
backend:
|
||||
cache:
|
||||
store: redis
|
||||
connection: user:pass@cache.example.com:6379
|
||||
connection: redis://user:pass@cache.example.com:6379
|
||||
```
|
||||
|
||||
Contributions supporting other cache stores are welcome!
|
||||
|
||||
Vendored
+1
-1
@@ -137,7 +137,7 @@ export interface Config {
|
||||
| {
|
||||
store: 'redis';
|
||||
/**
|
||||
* A redis connection string in the form `user:pass@host:port`.
|
||||
* A redis connection string in the form `redis://user:pass@host:port`.
|
||||
* @secret
|
||||
*/
|
||||
connection: string;
|
||||
|
||||
+3
-4
@@ -195,14 +195,13 @@ describe('CacheManager', () => {
|
||||
});
|
||||
|
||||
it('returns a Redis client when configured', () => {
|
||||
const redisHostAndPort = '127.0.0.1:6379';
|
||||
const expectedHost = `redis://${redisHostAndPort}`;
|
||||
const redisConnection = 'redis://127.0.0.1:6379';
|
||||
const manager = CacheManager.fromConfig(
|
||||
new ConfigReader({
|
||||
backend: {
|
||||
cache: {
|
||||
store: 'redis',
|
||||
connection: redisHostAndPort,
|
||||
connection: redisConnection,
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -218,7 +217,7 @@ describe('CacheManager', () => {
|
||||
expect(mockCacheCalls[0][0].store).toBeInstanceOf(KeyvRedis);
|
||||
const redis = KeyvRedis as jest.Mock;
|
||||
const mockRedisCalls = redis.mock.calls.splice(-1);
|
||||
expect(mockRedisCalls[0][0]).toEqual(expectedHost);
|
||||
expect(mockRedisCalls[0][0]).toEqual(redisConnection);
|
||||
});
|
||||
|
||||
describe('connection errors', () => {
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ export class CacheManager {
|
||||
return new Keyv({
|
||||
namespace: pluginId,
|
||||
ttl: defaultTtl,
|
||||
store: new KeyvRedis(`redis://${this.connection}`),
|
||||
store: new KeyvRedis(this.connection),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user