Files
RSSHub/lib/utils/cache/memory.ts
T
dependabot[bot]andTony 372cca9932 chore(deps): bump the oxc group across 1 directory with 5 updates (#23380)
* chore(deps): bump the oxc group across 1 directory with 5 updates

Bumps the oxc group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [oxc-parser](https://github.com/oxc-project/oxc/tree/HEAD/napi/parser) | `0.150.0` | `0.151.0` |
| [@oxlint/plugins](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint-plugins) | `1.83.0` | `1.85.0` |
| [oxfmt](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxfmt) | `0.68.0` | `0.70.0` |
| [oxlint](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint) | `1.83.0` | `1.85.0` |
| [oxlint-plugin-eslint](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint-plugin-eslint) | `1.83.0` | `1.85.0` |



Updates `oxc-parser` from 0.150.0 to 0.151.0
- [Release notes](https://github.com/oxc-project/oxc/releases)
- [Changelog](https://github.com/oxc-project/oxc/blob/main/napi/parser/CHANGELOG.md)
- [Commits](https://github.com/oxc-project/oxc/commits/crates_v0.151.0/napi/parser)

Updates `@oxlint/plugins` from 1.83.0 to 1.85.0
- [Release notes](https://github.com/oxc-project/oxc/releases)
- [Changelog](https://github.com/oxc-project/oxc/blob/main/CHANGELOG.md)
- [Commits](https://github.com/oxc-project/oxc/commits/oxlint_v1.85.0/npm/oxlint-plugins)

Updates `oxfmt` from 0.68.0 to 0.70.0
- [Release notes](https://github.com/oxc-project/oxc/releases)
- [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxfmt/CHANGELOG.md)
- [Commits](https://github.com/oxc-project/oxc/commits/oxfmt_v0.70.0/npm/oxfmt)

Updates `oxlint` from 1.83.0 to 1.85.0
- [Release notes](https://github.com/oxc-project/oxc/releases)
- [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxlint/CHANGELOG.md)
- [Commits](https://github.com/oxc-project/oxc/commits/oxlint_v1.85.0/npm/oxlint)

Updates `oxlint-plugin-eslint` from 1.83.0 to 1.85.0
- [Release notes](https://github.com/oxc-project/oxc/releases)
- [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxlint-plugin-eslint/CHANGELOG.md)
- [Commits](https://github.com/oxc-project/oxc/commits/oxlint_v1.85.0/npm/oxlint-plugin-eslint)

---
updated-dependencies:
- dependency-name: "@oxlint/plugins"
  dependency-version: 1.85.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: oxc
- dependency-name: oxc-parser
  dependency-version: 0.151.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: oxc
- dependency-name: oxfmt
  dependency-version: 0.70.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: oxc
- dependency-name: oxlint
  dependency-version: 1.85.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: oxc
- dependency-name: oxlint-plugin-eslint
  dependency-version: 1.85.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: oxc
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: disable unicorn rules that overlaps with oxc native one

* style: fix no-unnecessary-boolean-literal-compare

* style: fix no-unnecessary-type-conversion

* style: add all oxc/* correctness rules

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
2026-09-26 00:34:54 +08:00

40 lines
1.2 KiB
TypeScript

import { LRUCache } from 'lru-cache';
import { config } from '@/config';
import type CacheModule from './base';
import { stringify } from './base';
const status = { available: false };
const clients: CacheModule['clients'] = {};
export default {
init: () => {
clients.memoryCache = new LRUCache({
ttl: config.cache.routeExpire * 1000,
max: config.memory.max,
});
status.available = true;
},
get: (key: string, refresh = true) => {
if (key && status.available && clients.memoryCache) {
return clients.memoryCache.get(key, { updateAgeOnGet: refresh }) ?? null;
}
return null;
},
has: (key: string) => {
if (key && status.available && clients.memoryCache) {
return clients.memoryCache.has(key);
}
return false;
},
set: <T>(key: string, value?: string | T, maxAge = config.cache.contentExpire) => {
const stored = stringify(value);
if (key && status.available && clients.memoryCache) {
return clients.memoryCache.set(key, stored, { ttl: maxAge * 1000 });
}
},
clients,
status,
} satisfies CacheModule;