Skip to content

Commit

Permalink
adding in redis cluster compose
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredwray committed Nov 22, 2024
1 parent 1b6cf3a commit e15ab41
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/redis/test/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,20 @@ describe('KeyvRedis Cluster', () => {
});

test('should be able to set a value', async () => {

Check failure on line 45 in packages/redis/test/cluster.ts

View workflow job for this annotation

GitHub Actions / Node 20

Block must not be padded by blank lines.

Check failure on line 45 in packages/redis/test/cluster.ts

View workflow job for this annotation

GitHub Actions / Node 20

Block must not be padded by blank lines.

Check failure on line 45 in packages/redis/test/cluster.ts

View workflow job for this annotation

GitHub Actions / Node 22

Block must not be padded by blank lines.

const cluster = createCluster(defaultClusterOptions);

const keyvRedis = new KeyvRedis(cluster);

const undefinedResult = await keyvRedis.get('test-cl');
expect(undefinedResult).toBeUndefined();

await keyvRedis.set('test-cl', 'test');

const result = await keyvRedis.get('test-cl');

expect(result).toBe('test');

await keyvRedis.delete('test-cl');
});
});
39 changes: 39 additions & 0 deletions redis-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
x-redis-cluster-base: &redis-cluster-base
image: docker.io/bitnami/redis-cluster:latest
network_mode: host

services:
redis-cluster-1:
container_name: redis-cluster-1
<<: *redis-cluster-base
environment:
- 'ALLOW_EMPTY_PASSWORD=yes'
- 'REDIS_NODES=127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003'
- 'REDIS_CLUSTER_DYNAMIC_IPS=no'
- 'REDIS_CLUSTER_ANNOUNCE_IP=127.0.0.1'
- 'REDIS_PORT_NUMBER=7001'

redis-cluster-2:
container_name: redis-cluster-2
<<: *redis-cluster-base
environment:
- 'ALLOW_EMPTY_PASSWORD=yes'
- 'REDIS_NODES=127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003'
- 'REDIS_CLUSTER_DYNAMIC_IPS=no'
- 'REDIS_CLUSTER_ANNOUNCE_IP=127.0.0.1'
- 'REDIS_PORT_NUMBER=7002'

redis-cluster-3:
container_name: redis-cluster-3
<<: *redis-cluster-base
depends_on:
- redis-cluster-1
- redis-cluster-2
environment:
- 'ALLOW_EMPTY_PASSWORD=yes'
- 'REDIS_NODES=127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003'
- 'REDIS_CLUSTER_DYNAMIC_IPS=no'
- 'REDIS_CLUSTER_ANNOUNCE_IP=127.0.0.1'
- 'REDIS_PORT_NUMBER=7003'
- 'REDIS_CLUSTER_REPLICAS=0'
- 'REDIS_CLUSTER_CREATOR=yes'

0 comments on commit e15ab41

Please sign in to comment.