Skip to content

Commit e64d16d

Browse files
authored
Merge pull request #9 from alexpota/feat/valkey-glide-support
feat: add Valkey GLIDE support
2 parents e1cd4a1 + 99120a7 commit e64d16d

File tree

5 files changed

+77
-20
lines changed

5 files changed

+77
-20
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.3.0]
9+
10+
### Added
11+
12+
- **Valkey GLIDE Support**: Added support for Valkey's official GLIDE client via `GlideAdapter`
13+
- **Re-exported Adapters**: `NodeRedisAdapter`, `IoredisAdapter`, and `GlideAdapter` are now re-exported from `nestjs-redlock-universal` for convenience
14+
- Updated peer dependency to `redlock-universal ^0.8.0`
15+
16+
### Documentation
17+
18+
- Added Valkey GLIDE configuration examples
19+
- Updated all examples to use re-exported adapters from `nestjs-redlock-universal`
20+
- Updated features list to mention Valkey support
21+
822
## [0.1.0] - 2025-01-05
923

1024
### Added

README.md

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# nestjs-redlock-universal
22

3-
> NestJS integration for [redlock-universal](https://www.npmjs.com/package/redlock-universal) - Distributed Redis locks with decorators and dependency injection
3+
> NestJS integration for [redlock-universal](https://www.npmjs.com/package/redlock-universal) - Distributed Redis and Valkey locks with decorators and dependency injection
44
55
[![npm version](https://img.shields.io/npm/v/nestjs-redlock-universal.svg)](https://www.npmjs.com/package/nestjs-redlock-universal)
66
[![npm downloads](https://img.shields.io/npm/dm/nestjs-redlock-universal.svg)](https://www.npmjs.com/package/nestjs-redlock-universal)
@@ -9,22 +9,24 @@
99

1010
## Overview
1111

12-
NestJS wrapper for [redlock-universal](https://www.npmjs.com/package/redlock-universal), providing **distributed Redis locks** through NestJS decorators, modules, and dependency injection.
12+
NestJS wrapper for [redlock-universal](https://www.npmjs.com/package/redlock-universal), providing **distributed Redis and Valkey locks** through NestJS decorators, modules, and dependency injection.
1313

1414
## Features
1515

1616
- **NestJS Native**: First-class integration with dependency injection and lifecycle hooks
17-
- **Distributed Locks**: Redlock algorithm for multi-instance Redis setups
17+
- **Distributed Locks**: Redlock algorithm for multi-instance Redis/Valkey setups
1818
- **Simple API**: Method decorator for zero-boilerplate distributed locking
1919
- **High Performance**: <1ms lock acquisition with automatic extension
2020
- **Type-Safe**: Full TypeScript support with strict type checking
21-
- **Universal**: Works with both `node-redis` v4+ and `ioredis` v5+ clients
21+
- **Universal**: Works with `node-redis` v4+, `ioredis` v5+, and Valkey GLIDE v2+
2222

2323
## Table of Contents
2424

2525
- [Installation](#installation)
2626
- [Quick Start](#quick-start)
2727
- [Configuration](#configuration)
28+
- [Using ioredis](#using-ioredis)
29+
- [Using Valkey GLIDE](#using-valkey-glide)
2830
- [API Reference](#api-reference)
2931
- [Advanced Usage](#advanced-usage)
3032
- [Testing](#testing)
@@ -39,14 +41,17 @@ This package wraps `redlock-universal`, so you need to install both packages:
3941
npm install nestjs-redlock-universal redlock-universal
4042
```
4143

42-
You'll also need a Redis client:
44+
You'll also need a Redis/Valkey client:
4345

4446
```bash
4547
# For node-redis
4648
npm install redis
4749

4850
# OR for ioredis
4951
npm install ioredis
52+
53+
# OR for Valkey GLIDE (official Valkey client)
54+
npm install @valkey/valkey-glide
5055
```
5156

5257
## Quick Start
@@ -55,8 +60,7 @@ npm install ioredis
5560

5661
```typescript
5762
import { Module } from '@nestjs/common';
58-
import { RedlockModule } from 'nestjs-redlock-universal';
59-
import { NodeRedisAdapter } from 'redlock-universal';
63+
import { RedlockModule, NodeRedisAdapter } from 'nestjs-redlock-universal';
6064
import { createClient } from 'redis';
6165

6266
// Create and connect Redis clients
@@ -138,8 +142,7 @@ export class OrderService {
138142
### Synchronous Configuration
139143

140144
```typescript
141-
import { RedlockModule } from 'nestjs-redlock-universal';
142-
import { NodeRedisAdapter } from 'redlock-universal';
145+
import { RedlockModule, NodeRedisAdapter } from 'nestjs-redlock-universal';
143146

144147
RedlockModule.forRoot({
145148
nodes: [
@@ -159,6 +162,7 @@ RedlockModule.forRoot({
159162

160163
```typescript
161164
import { ConfigService } from '@nestjs/config';
165+
import { RedlockModule, NodeRedisAdapter } from 'nestjs-redlock-universal';
162166

163167
RedlockModule.forRootAsync({
164168
useFactory: async (configService: ConfigService) => {
@@ -179,7 +183,7 @@ RedlockModule.forRootAsync({
179183
### Using ioredis
180184

181185
```typescript
182-
import { IoredisAdapter } from 'redlock-universal';
186+
import { RedlockModule, IoredisAdapter } from 'nestjs-redlock-universal';
183187
import Redis from 'ioredis';
184188

185189
const redis1 = new Redis({ host: 'localhost', port: 6379 });
@@ -195,6 +199,32 @@ RedlockModule.forRoot({
195199
})
196200
```
197201

202+
### Using Valkey GLIDE
203+
204+
```typescript
205+
import { RedlockModule, GlideAdapter } from 'nestjs-redlock-universal';
206+
import { GlideClient } from '@valkey/valkey-glide';
207+
208+
// Create Valkey GLIDE clients
209+
const valkey1 = await GlideClient.createClient({
210+
addresses: [{ host: 'localhost', port: 6379 }],
211+
});
212+
const valkey2 = await GlideClient.createClient({
213+
addresses: [{ host: 'localhost', port: 6380 }],
214+
});
215+
const valkey3 = await GlideClient.createClient({
216+
addresses: [{ host: 'localhost', port: 6381 }],
217+
});
218+
219+
RedlockModule.forRoot({
220+
nodes: [
221+
new GlideAdapter(valkey1),
222+
new GlideAdapter(valkey2),
223+
new GlideAdapter(valkey3),
224+
],
225+
})
226+
```
227+
198228
### Logger Integration
199229

200230
The module supports external loggers for lock operations. Winston works directly, while Pino and Bunyan require adapters:
@@ -362,6 +392,9 @@ export class AdvancedService {
362392
For development or single-instance deployments:
363393

364394
```typescript
395+
import { RedlockModule, NodeRedisAdapter } from 'nestjs-redlock-universal';
396+
import { createClient } from 'redis';
397+
365398
const redis = createClient({ url: 'redis://localhost:6379' });
366399
await redis.connect();
367400

@@ -535,7 +568,7 @@ Most NestJS Redis libraries focus on caching. This library is purpose-built for
535568
- ✅ Automatic lock extension via `using()`
536569
- ✅ NestJS decorator for zero-boilerplate
537570
- ✅ Built on `redlock-universal`
538-
- ✅ Universal Redis client support (node-redis + ioredis)
571+
- ✅ Universal Redis/Valkey client support (node-redis, ioredis, Valkey GLIDE)
539572

540573
## License
541574

package-lock.json

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
22
"name": "nestjs-redlock-universal",
3-
"version": "0.2.3",
4-
"description": "NestJS integration for redlock-universal - Distributed Redis locks with decorators, modules, and dependency injection",
3+
"version": "0.3.0",
4+
"description": "NestJS integration for redlock-universal - Distributed Redis and Valkey locks with decorators, modules, and dependency injection",
55
"keywords": [
66
"nestjs",
77
"nest",
88
"redlock",
99
"redis",
10+
"valkey",
11+
"valkey-glide",
12+
"valkey-lock",
1013
"lock",
1114
"distributed",
1215
"distributed-lock",
@@ -90,7 +93,7 @@
9093
"peerDependencies": {
9194
"@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
9295
"@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
93-
"redlock-universal": "^0.7.5",
96+
"redlock-universal": "^0.8.0",
9497
"reflect-metadata": "^0.1.13 || ^0.2.0"
9598
},
9699
"devDependencies": {
@@ -110,7 +113,7 @@
110113
"lint-staged": "^16.2.6",
111114
"prettier": "^3.0.0",
112115
"redis": "^5.9.0",
113-
"redlock-universal": "^0.7.5",
116+
"redlock-universal": "^0.8.0",
114117
"reflect-metadata": "^0.1.13",
115118
"tsup": "^8.0.0",
116119
"typescript": "^5.2.0",

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ export {
2121
DEFAULT_RETRY_DELAY_MS,
2222
MIN_NODES_FOR_REDLOCK,
2323
} from './constants';
24+
25+
// Re-export adapters from redlock-universal for convenience
26+
export { NodeRedisAdapter, IoredisAdapter, GlideAdapter } from 'redlock-universal';

0 commit comments

Comments
 (0)