Skip to content

Commit 5a04e8e

Browse files
author
Kushagra Singh Bisen
committed
changed redis client to ioredis
1 parent a5accb9 commit 5a04e8e

12 files changed

+189
-22
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ An initial architecutre (not final) of the Solid Stream Notifications Cache is s
66

77
![Solid Stream Notifications Cache Architecture](./architecture.png)
88

9+
- In the current architecture, we only work with the webhook notification of the solid pods and cache them. We don't support websocket notifications yet as they are not very scalabble.(but would appreciate a PR for that in case you wish to implement it).
10+
911
## License
1012
This code is copyrighted by [Ghent University - imec](https://www.ugent.be/ea/idlab/en) and released under the [MIT License](./LICENSE).
1113

package-lock.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"devDependencies": {
1818
"@types/bunyan": "^1.8.11",
1919
"@types/jest": "^29.2.4",
20+
"@types/node": "^20.11.24",
2021
"eslint": "^8.57.0",
2122
"eslint-plugin-jest": "^27.9.0",
2223
"eslint-plugin-jsdoc": "^48.2.0",
@@ -29,6 +30,6 @@
2930
"@types/redis": "^4.0.11",
3031
"@typescript-eslint/parser": "^7.1.0",
3132
"bunyan": "^1.8.15",
32-
"redis": "^4.6.13"
33+
"ioredis": "^5.3.2"
3334
}
3435
}

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ program
2828

2929
program
3030
.command('cache-notifications')
31-
.description('Starts the cache service for notifications from the solid server(s).')
31+
.description('Starts the cache service for notifications from the LDES stream stored in the solid server(s).')
3232
.option('-p, --port <port>', 'The port where the HTTP server will listen.', '8085')
33-
.option('-p --pod <pod>', 'The location of the Solid Pod', 'http://localhost:3000/aggregation_pod/')
33+
.option('-l --ldes <ldes>', 'The location of the LDES Stream', 'http://localhost:3000/aggregation_pod/aggregation/')
3434
.action((options: any) => {
3535
new CacheServiceHTTPServer(options.port, options.pod, logger);
3636
});

src/service/CacheService.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,21 @@ describe('CacheService', () => {
1111
await cacheService.disconnect();
1212
});
1313

14-
it('should_connect_to_the_cache', async () => {
15-
const connected = await cacheService.connect();
16-
expect(connected).toBe(true);
17-
});
18-
1914
it('should_set_and_get_a_value', async () => {
20-
await cacheService.connect();
2115
await cacheService.set('key', 'value');
2216
const value = await cacheService.get('key');
2317
expect(value).toBe('value');
2418
});
2519

2620
it('should_delete_a_value', async () => {
27-
await cacheService.connect();
2821
await cacheService.set('key', 'value');
2922
await cacheService.delete('key');
3023
const value = await cacheService.get('key');
3124
expect(value).toBe(null);
3225
});
3326

3427
it('should_close_the_connection', async () => {
35-
28+
const is_disconnected = await cacheService.disconnect();
29+
expect(is_disconnected).toBe(true);
3630
});
3731
});

src/service/CacheService.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { createClient } from "redis";
1+
import { Redis } from "ioredis";
22
/**
33
* A service for interacting with the Redis cache.
44
* @class CacheService
55
*/
66
export class CacheService {
7-
private client: any;
7+
public client: any;
88
/**
99
* Creates an instance of CacheService.
1010
* @memberof CacheService
1111
*/
1212
constructor() {
13-
this.client = createClient({});
13+
// defaults to localhost:6379 if no options are provided, which is the default for Redis.
14+
this.client = new Redis({});
1415
this.setupListeners();
1516
}
1617
/**
@@ -66,6 +67,7 @@ export class CacheService {
6667
*/
6768
async disconnect() {
6869
await this.client.quit();
70+
return true;
6971
}
7072

7173
/**

src/service/SubscribeNotification.test.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)