Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Test

on: [push, pull_request, workflow_dispatch]
on:
pull_request:
push:
branches:
- main
workflow_dispatch:

jobs:
test:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [5.0.0] - 2026-08-04
See the [v4 to v5 migration guide](docs/v4-to-v5.md).
### Added
- `pettyCache.close()` stops the background refresh intervals started by `fetchAndRefresh` and gracefully closes the Redis client connection.
### Changed
- Callback support is removed. Every function returns a promise; passing a callback rejects with a `TypeError`.
- Cache-miss functions and `retrieveOrCreate`'s `size` option must be async (or plain-return) functions; callback-style functions are no longer supported.
- Upgraded the `redis` client from v3 to v6. The client is connected automatically, and injected clients must be node-redis v6 clients.
- The constructor takes a node-redis v6 options object, passed to `redis.createClient()` untouched. The `(port, [host, [options]])` signature and node-redis v3 option names (`auth_pass`, `host`, `port`, `enable_offline_queue`, and friends) are no longer supported.
## [4.0.1] - 2026-08-05
### Fixed
- A callback that throws is no longer invoked a second time with its own error. Callbacks are now invoked on the next tick, outside of the promise chain, so a throw from within a callback surfaces as an uncaught exception instead of being swallowed. Affects every callback-style function.
Expand Down
7 changes: 3 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm test
npm run coveralls

# Run a single test file
npx mocha test/index.js
node --test --test-force-exit --test-reporter=spec test/index.js
```

### Linting
Expand All @@ -36,11 +36,10 @@ npm install

### Core Structure
- **Main Entry**: `index.js` - Contains the PettyCache class and all public API methods
- **Test Suite**: `test/index.js` - Comprehensive Mocha test suite testing all cache operations, mutex, and semaphore functionality
- **Test Suite**: `test/index.js` - Comprehensive node:test suite testing all cache operations, mutex, and semaphore functionality
- **Dependencies**:
- `redis` (v3.1.0) - Redis client for distributed caching
- `redis` (v6) - Redis client for distributed caching; petty-cache connects it automatically
- `memory-cache` (v0.2.0) - In-memory cache for recently accessed data
- `async` (v3.2.6) - Async utility functions
- `lock` (v1.1.0) - Local locking mechanism

### Key Design Patterns
Expand Down
Loading