Skip to content

Commit

Permalink
fix(deps): replace lru-cache with toad-cache (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Nov 15, 2024
1 parent 7861dd5 commit 43b97a6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
21 changes: 10 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@octokit/request": "^9.1.1",
"@octokit/request-error": "^6.1.1",
"@octokit/types": "^13.4.1",
"lru-cache": "npm:@wolfy1339/lru-cache@^11.0.2-patch.1",
"toad-cache": "^3.7.0",
"universal-github-app-jwt": "^2.2.0",
"universal-user-agent": "^7.0.0"
},
Expand Down
11 changes: 5 additions & 6 deletions src/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// https://github.com/isaacs/node-lru-cache#readme
import { LRUCache } from "lru-cache";
import { Lru } from "toad-cache";

/* v8 ignore next */
import type {
Expand All @@ -12,12 +11,12 @@ import type {
} from "./types.js";

export function getCache() {
return new LRUCache<number, string>({
return new Lru<string>(
// cache max. 15000 tokens, that will use less than 10mb memory
max: 15000,
15000,
// Cache for 1 minute less than GitHub expiry
ttl: 1000 * 60 * 59,
});
1000 * 60 * 59,
);
}

export async function get(
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as OctokitTypes from "@octokit/types";
import type { LRUCache } from "lru-cache";
import type { Lru } from "toad-cache";
import type * as OAuthAppAuth from "@octokit/auth-oauth-app";

// STRATEGY OPTIONS
Expand Down Expand Up @@ -134,7 +134,7 @@ export type Route = OctokitTypes.Route;
export type RequestInterface = OctokitTypes.RequestInterface;

export type Cache =
| LRUCache<string, string>
| Lru<string>
| {
get: (key: string) => string | Promise<string>;
set: (key: string, value: string) => any;
Expand Down

0 comments on commit 43b97a6

Please sign in to comment.