Skip to content

Commit

Permalink
wip(LRUCache): 更新 reason 的类型
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Aug 1, 2024
1 parent 8112316 commit 2de1129
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ jobs:
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# cache: 'pnpm'

- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
with:
version: 8
version: 9

- name: Install dependencies
run: pnpm install --ignore-scripts
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.com

- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down
6 changes: 3 additions & 3 deletions src/common/lib/LRUCache.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @see https://www.npmjs.com/package/lru-cache

type DisposeReason = 'set' | 'delete' | 'evict' | 'expired';
export interface LRUCacheOptions<K = string, V = unknown> {
/** The maximum number of items that remain in the cache. default 500 */
max?: number;
/** how long to live in ms. default 0 */
ttl?: number;
updateAgeOnGet?: boolean;
/** Function that is called on items when they are dropped from the cache */
dispose?(val: LRUCacheItem<V>, key: K, reason: string): void;
dispose?(val: LRUCacheItem<V>, key: K, reason: DisposeReason): void;
}

interface LRUCacheItem<V> {
Expand Down Expand Up @@ -65,7 +65,7 @@ export class LRUCache<K = string, V = unknown> {
return value.v as T;
}
/** Deletes a key out of the cache */
delete(key: K, reason = 'delete') {
delete(key: K, reason: DisposeReason = 'delete') {
if (!this.cache.has(key)) return false;
const val = this.cache.get(key);
this.cache.delete(key);
Expand Down

0 comments on commit 2de1129

Please sign in to comment.