Skip to content

Commit

Permalink
Merge pull request #7 from hyper63/twilson63/cluster-enabled-flag
Browse files Browse the repository at this point in the history
add cluster enabled flag in options
  • Loading branch information
twilson63 authored Oct 18, 2021
2 parents e168992 + 2cccaa6 commit 51d39c7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
deno-version: [1.13.x, 1.14.x]
deno-version: [1.x]
steps:
- uses: actions/checkout@v2
- name: Use Deno ${{ matrix.deno-version }}
Expand Down
2 changes: 1 addition & 1 deletion adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function (client) {
.map(
ifElse(
() => not(isNil(ttl)),
append(({ px: ttl })),
append({ px: ttl }),
identity,
),
)
Expand Down
10 changes: 7 additions & 3 deletions mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ const { mergeRight } = R;
*/
export default function RedisCacheAdapter(
config = {},
options = { client: redis },
options = { client: redis, cluster: false },
) {
options.client = options.client || redis;

async function load(prevLoad = {}) {
// prefer args passed to adapter over previous load
config = mergeRight(prevLoad, config);

const client = await options.client.connect(config);
if (options.cluster) {
await options.client.clusterMeet(config.hostname, 6380);
await options.client.clusterNodes();
}
// create client
return { client: await options.client.connect(config) };
return { client };
}

/**
Expand Down
4 changes: 1 addition & 3 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

deno lint && \
deno fmt --check && \
deno test adapter_test.js
deno lint && deno fmt --check && deno test adapter_test.js

0 comments on commit 51d39c7

Please sign in to comment.