Skip to content

Commit

Permalink
fix: change import from default to named one
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirke committed Aug 17, 2022
1 parent ff4e4c1 commit 6e35cb9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ This is a rewrite of [dabroek/node-cache-manager-ioredis](https://github.com/dab
It uses TypeScript with updated dependencies and missing features added.
It aims to provide **the most simple wrapper possible** by just passing the configuration to the underlying [`ioredis`](https://github.com/luin/ioredis) package.

Installation
------------
## Installation

```sh
npm install @tirke/cache-manager-ioredis
```

```sh
yarn add @tirke/cache-manager-ioredis
```

```sh
pnpm add @tirke/cache-manager-ioredis
```

Usage Examples
--------------
## Usage Examples

### Using promises

```typescript
import RedisStore, { Store } from '@tirke/cache-manager-ioredis'
import { IoRedisStore, Store } from '@tirke/cache-manager-ioredis'
import { caching } from 'cache-manager'

const redisCache = caching({
store: RedisStore,
store: IoRedisStore,
host: 'localhost', // default value
port: 6379, // default value
password: 'XXXXX',
Expand All @@ -42,7 +42,7 @@ const redisCache = caching({

// listen for redis connection error event
const cache = redisCache.store as Store
const redisClient = cache.getClient();
const redisClient = cache.getClient()
redisClient.on('error', (error: unknown) => {
// handle error here
console.log(error)
Expand Down
17 changes: 10 additions & 7 deletions packages/node-cache-manager-ioredis/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
[![codecov](https://codecov.io/gh/Tirke/node-cache-manager-ioredis/branch/main/graph/badge.svg?token=8B6YUE99N3)](https://codecov.io/gh/Tirke/node-cache-manager-ioredis)
[![npm version](https://badge.fury.io/js/@tirke%2Fnode-cache-manager-ioredis.svg)](https://badge.fury.io/js/@tirke%2Fnode-cache-manager-ioredis)

# IORedis store for node cache manager

Redis cache store for [node-cache-manager](https://github.com/BryanDonovan/node-cache-manager).

This is a rewrite of [dabroek/node-cache-manager-ioredis](https://github.com/dabroek/node-cache-manager-ioredis).
It uses TypeScript with updated dependencies and missing features added.
It aims to provide **the most simple wrapper possible** by just passing the configuration to the underlying [`ioredis`](https://github.com/luin/ioredis) package.

Installation
------------
## Installation

```sh
npm install @tirke/cache-manager-ioredis
```

```sh
yarn add @tirke/cache-manager-ioredis
```

```sh
pnpm add @tirke/cache-manager-ioredis
```

Usage Examples
--------------
## Usage Examples

### Using promises

```typescript
import RedisStore, { Store } from '@tirke/cache-manager-ioredis'
import { IoRedisStore, Store } from '@tirke/cache-manager-ioredis'
import { caching } from 'cache-manager'

const redisCache = caching({
store: RedisStore,
store: IoRedisStore,
host: 'localhost', // default value
port: 6379, // default value
password: 'XXXXX',
Expand All @@ -39,7 +42,7 @@ const redisCache = caching({

// listen for redis connection error event
const cache = redisCache.store as Store
const redisClient = cache.getClient();
const redisClient = cache.getClient()
redisClient.on('error', (error: unknown) => {
// handle error here
console.log(error)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Cache, caching } from 'cache-manager'
import Redis, { Callback, RedisOptions } from 'ioredis'

import RedisStore, { Store } from './node-cache-manager-ioredis'
import { IoRedisStore, Store } from './node-cache-manager-ioredis'

let redisCache: Cache
let customRedisCache: Cache
Expand All @@ -18,7 +18,7 @@ const config = {

beforeEach((done) => {
redisCache = caching({
store: RedisStore,
store: IoRedisStore,
ttl: config.ttl,
instanceConfig: {
host: config.host,
Expand All @@ -29,7 +29,7 @@ beforeEach((done) => {
})

customRedisCache = caching({
store: RedisStore,
store: IoRedisStore,
instanceConfig: {
host: config.host,
port: config.port,
Expand All @@ -50,7 +50,7 @@ beforeEach((done) => {
describe('init', () => {
it('should create a store with password instead of auth_pass (auth_pass is deprecated for redis > 2.5)', (done) => {
const redisPwdCache = caching({
store: RedisStore,
store: IoRedisStore,
ttl: config.ttl,
instanceConfig: {
host: config.host,
Expand All @@ -75,7 +75,7 @@ describe('init', () => {

it('should create a store with an external Redis instance', (done) => {
const externalRedisInstanceCache = caching({
store: RedisStore,
store: IoRedisStore,
redisInstance: new Redis({
host: config.host,
port: config.port,
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('set', () => {

it('should throw on circular object stringifies', async () => {
const allowNullCache = caching({
store: RedisStore,
store: IoRedisStore,
instanceConfig: {
host: config.host,
port: config.port,
Expand Down Expand Up @@ -293,7 +293,7 @@ describe('ttl', () => {

it('external Redis instance should respect top level ttl', async () => {
const externalRedisInstanceCache = caching({
store: RedisStore,
store: IoRedisStore,
redisInstance: new Redis({
host: config.host,
port: config.port,
Expand Down Expand Up @@ -376,7 +376,7 @@ describe('defaults are set by redis itself', () => {

beforeEach(() => {
defaultRedisCache = caching({
store: RedisStore,
store: IoRedisStore,
ttl: 12,
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function isObject(value: any): value is Record<string, unknown> {
return value && value instanceof Object && value.constructor === Object
}

export default {
export const IoRedisStore = {
create(args: CreateArgs) {
const isCacheableValue = args.isCacheableValue || ((value) => value !== undefined && value !== null)
return new RedisStore({ ...args, isCacheableValue })
Expand Down

0 comments on commit 6e35cb9

Please sign in to comment.