Skip to content

Commit 42472f4

Browse files
authored
Merge pull request #29 from trieb-work/fix-readme
Fix: allign all config options to be camelcase (`redis_url` becomes `redisUrl`) + fix: readme test startup
2 parents 340dc7f + a57fd6a commit 42472f4

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# nextjs-turbo-redis-cache
2+
23
[![npm version](https://img.shields.io/npm/v/@trieb.work/nextjs-turbo-redis-cache.svg)](https://www.npmjs.com/package/@trieb.work/nextjs-turbo-redis-cache)
34
![Turbo redis cache image](https://github.com/user-attachments/assets/98e0dfd9-f38a-42ad-a355-9843740cc2d6)
45

@@ -118,7 +119,7 @@ A working example of above can be found in the `test/integration/next-app-custom
118119

119120
| Option | Description | Default Value |
120121
| ---------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
121-
| redis_url | Redis connection url | `process.env.REDIS_URL? process.env.REDIS_URL : process.env.REDISHOST ? redis://${process.env.REDISHOST}:${process.env.REDISPORT} : 'redis://localhost:6379'` |
122+
| redisUrl | Redis connection url | `process.env.REDIS_URL? process.env.REDIS_URL : process.env.REDISHOST ? redis://${process.env.REDISHOST}:${process.env.REDISPORT} : 'redis://localhost:6379'` |
122123
| database | Redis database number to use. Uses DB 0 for production, DB 1 otherwise | `process.env.VERCEL_ENV === 'production' ? 0 : 1` |
123124
| keyPrefix | Prefix added to all Redis keys | `process.env.VERCEL_URL \|\| 'UNDEFINED_URL_'` |
124125
| sharedTagsKey | Key used to store shared tags hash map in Redis | `'__sharedTags__'` |
@@ -171,28 +172,26 @@ By accepting and tolerating this eventual consistency, the performance of the ca
171172

172173
## Testing
173174

174-
Run `pnpm run-dev-server` to start the nextjs integration test project.
175-
176-
To run all tests you can use the following command in a second terminal:
175+
To run all tests you can use the following command:
177176

178177
```bash
179-
pnpm test
178+
pnpm build && pnpm test
180179
```
181180

182181
### Unit tests
183182

184183
To run unit tests you can use the following command:
185184

186185
```bash
187-
pnpm test:unit
186+
pnpm build && pnpm test:unit
188187
```
189188

190189
### Integration tests
191190

192191
To run integration tests you can use the following command:
193192

194193
```bash
195-
pnpm test:integration
194+
pnpm build && pnpm test:integration
196195
```
197196

198197
The integration tests will start a Next.js server and test the caching handler. You can modify testing behavior by setting the following environment variables:

src/RedisStringsHandler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ export type CacheEntry = {
1414
};
1515

1616
export type CreateRedisStringsHandlerOptions = {
17-
/** Redis redis_url to use.
17+
/** Redis redisUrl to use.
1818
* @default process.env.REDIS_URL? process.env.REDIS_URL : process.env.REDISHOST
1919
? `redis://${process.env.REDISHOST}:${process.env.REDISPORT}`
2020
: 'redis://localhost:6379'
2121
*/
22-
redis_url?: string;
22+
redisUrl?: string;
2323
/** Redis database number to use. Uses DB 0 for production, DB 1 otherwise
2424
* @default process.env.VERCEL_ENV === 'production' ? 0 : 1
2525
*/
@@ -97,7 +97,7 @@ export default class RedisStringsHandler {
9797
private estimateExpireAge: (staleAge: number) => number;
9898

9999
constructor({
100-
redis_url = process.env.REDIS_URL
100+
redisUrl = process.env.REDIS_URL
101101
? process.env.REDIS_URL
102102
: process.env.REDISHOST
103103
? `redis://${process.env.REDISHOST}:${process.env.REDISPORT}`
@@ -124,7 +124,7 @@ export default class RedisStringsHandler {
124124
try {
125125
this.client = createClient({
126126
...(database !== 0 ? { database } : {}),
127-
url: redis_url,
127+
url: redisUrl,
128128
});
129129

130130
this.client.on('error', (error) => {

0 commit comments

Comments
 (0)