Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
caijf committed May 29, 2024
1 parent 55f51e3 commit d168595
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ local.get('foo');
```typescript
import { Cache } from 'cache2';
const myCache = new Cache();
const myCache = new Cache(namespace?, options?);
```
### set(key: string, value: any, ttl?: number)
Expand Down Expand Up @@ -340,7 +340,7 @@ myCache.on('expired', (key, value) => {
```typescript
import { Cache } from 'cache2';

const responseCache = new Cache({ max: 10, maxStrategy: 'replaced' });
const responseCache = new Cache('namespace', { max: 10, maxStrategy: 'replaced' });
// ...
```
Expand All @@ -349,7 +349,7 @@ const responseCache = new Cache({ max: 10, maxStrategy: 'replaced' });
```typescript
import { Cache } from 'cache2';

const fileCache = new Cache({ max: 20, maxStrategy: 'replaced' });
const fileCache = new Cache('namespace', { max: 20, maxStrategy: 'replaced' });
fileCache.on('del', (key, value) => {
URL.revokeObjectURL(value);
});
Expand All @@ -362,7 +362,7 @@ fileCache.set(fssid, URL.createObjectURL(file));
```typescript
import { Cache } from 'cache2';

const localCache = new Cache('storageKey', {
const localCache = new Cache({
storage: localStorage,
stdTTL: 5 * 60 * 1000 // 默认数据留存时间为5分钟
});
Expand Down Expand Up @@ -391,7 +391,7 @@ const wxStorage = {
wx.removeStorageSync(key);
}
};
const wxCache = new Cache('storageKey', {
const wxCache = new Cache('namespace', {
storage: wxStorage,
needParsed: false,
stdTTL: 5 * 60 * 1000 // 设置默认数据留存时间为5分钟
Expand Down

0 comments on commit d168595

Please sign in to comment.