Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bumps momento sdk to latest #40

Merged
merged 1 commit into from
Jun 12, 2024
Merged
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
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 21 additions & 59 deletions src/momento-redis-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
// TODO compile time checks on what methods are supported by the MomentoIORedis
// TODO interface. We could try defining our own ChainableMomento interface
// TODO instead here potentially
pipeline(commands?: Array<Array<any>>): ChainableCommander;

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

Unexpected any. Specify a different type

Check warning on line 192 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

Unexpected any. Specify a different type

quit(): Promise<'OK'>;

Expand Down Expand Up @@ -244,26 +244,24 @@
}
} else if (rsp instanceof CacheGet.Miss) {
return null;
} else if (rsp instanceof CacheGet.Error) {
this.emitError('get', rsp.message(), rsp.errorCode());
} else {
this.emitError('get', `unexpected-response ${rsp.toString()}`);
this.emitError('get', rsp.message(), rsp.errorCode());
}
return null;
}

// eslint-disable-next-line require-await, @typescript-eslint/require-await
async quit(): Promise<'OK'> {
this.momentoClient.close();
this.emit('end')
this.emit('end');
return 'OK';
}

disconnect(reconnect?: boolean): void {

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 16

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 18

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

'reconnect' is defined but never used

Check warning on line 260 in src/momento-redis-adapter.ts

View workflow job for this annotation

GitHub Actions / Test on Node 20

'reconnect' is defined but never used
// TODO handle reconnect event. re-make momento client?
this.momentoClient.close();
this.emit('end')
return
this.emit('end');
return;
}

emitError(op: string, msg: string, code?: MomentoErrorCode) {
Expand Down Expand Up @@ -396,13 +394,8 @@
return 'OK';
} else if (rsp instanceof CacheSetIfAbsent.NotStored) {
return null;
} else if (rsp instanceof CacheSetIfAbsent.Error) {
this.emitError('set-not-exists', rsp.message(), rsp.errorCode());
} else {
this.emitError(
'set-not-exists',
`unexpected-response ${rsp.toString()}`
);
this.emitError('set-not-exists', rsp.message(), rsp.errorCode());
}
} else {
let rsp: CacheSet.Response;
Expand All @@ -425,10 +418,8 @@

if (rsp instanceof CacheSet.Success) {
return 'OK';
} else if (rsp instanceof CacheSet.Error) {
this.emitError('set', rsp.message(), rsp.errorCode());
} else {
this.emitError('set', `unexpected-response ${rsp.toString()}`);
this.emitError('set', rsp.message(), rsp.errorCode());
}
}

Expand All @@ -455,10 +446,8 @@
const rsp = await this.momentoClient.increment(this.cacheName, key);
if (rsp instanceof CacheIncrement.Success) {
return rsp.value();
} else if (rsp instanceof CacheIncrement.Error) {
this.emitError('incr', rsp.message(), rsp.errorCode());
} else {
this.emitError('incr', `unexpected-response ${rsp.toString()}`);
this.emitError('incr', rsp.message(), rsp.errorCode());
}
return null;
}
Expand Down Expand Up @@ -530,12 +519,11 @@

if (rsp instanceof CacheDictionarySetFields.Success) {
return fieldsToSet.size;
} else if (rsp instanceof CacheDictionarySetFields.Error) {
this.emitError('hset', rsp.message(), rsp.errorCode());
return 0;
} else {
this.emitError('hset', `unexpected-response ${rsp.toString()}`);
return 0;
{
this.emitError('hset', rsp.message(), rsp.errorCode());
return 0;
}
}
}

Expand Down Expand Up @@ -582,11 +570,8 @@
}
} else if (rsp instanceof CacheDictionaryGetFields.Miss) {
return [];
} else if (rsp instanceof CacheDictionaryGetFields.Error) {
this.emitError('hmget', rsp.message(), rsp.errorCode());
return [];
} else {
this.emitError('hmget', `unexpected-response ${rsp.toString()}`);
this.emitError('hmget', rsp.message(), rsp.errorCode());
return [];
}
}
Expand All @@ -605,11 +590,8 @@
}
} else if (rsp instanceof CacheDictionaryGetField.Miss) {
return null;
} else if (rsp instanceof CacheDictionaryGetField.Error) {
this.emitError('hget', rsp.message(), rsp.errorCode());
return null;
} else {
this.emitError('hget', `unexpected-response ${rsp.toString()}`);
this.emitError('hget', rsp.message(), rsp.errorCode());
return null;
}
}
Expand All @@ -631,11 +613,8 @@
return record;
} else if (rsp instanceof CacheDictionaryFetch.Miss) {
return {};
} else if (rsp instanceof CacheDictionaryFetch.Error) {
this.emitError('hgetall', rsp.message(), rsp.errorCode());
return {};
} else {
this.emitError('hgetall', `unexpected-response ${rsp.toString()}`);
this.emitError('hgetall', rsp.message(), rsp.errorCode());
return {};
}
}
Expand All @@ -654,11 +633,8 @@
);
if (rsp instanceof CacheDictionaryRemoveFields.Success) {
return fields.length;
} else if (rsp instanceof CacheDictionaryRemoveFields.Error) {
this.emitError('hdel', rsp.message(), rsp.errorCode());
return 0;
} else {
this.emitError('hdel', `unexpected-response ${rsp.toString()}`);
this.emitError('hdel', rsp.message(), rsp.errorCode());
return 0;
}
}
Expand Down Expand Up @@ -709,11 +685,8 @@
const rsp = await this.momentoClient.setBatch(this.cacheName, items);
if (rsp instanceof CacheSetBatch.Success) {
return 'OK';
} else if (rsp instanceof CacheSetBatch.Error) {
this.emitError('mset', rsp.message(), rsp.errorCode());
return 'OK';
} else {
this.emitError('mset', `unexpected-response ${rsp.toString()}`);
this.emitError('mset', rsp.message(), rsp.errorCode());
return 'OK';
}
}
Expand Down Expand Up @@ -753,10 +726,8 @@
value !== null ? new TextDecoder().decode(value) : null
);
}
} else if (resp instanceof CacheGetBatch.Error) {
this.emitError('mget', resp.message(), resp.errorCode());
} else {
this.emitError('mget', `unexpected-response ${resp.toString()}`);
this.emitError('mget', resp.message(), resp.errorCode());
}
return [];
}
Expand All @@ -767,10 +738,8 @@
return rsp.remainingTtlMillis() / 1000;
} else if (rsp instanceof CacheItemGetTtl.Miss) {
return null;
} else if (rsp instanceof CacheItemGetTtl.Error) {
this.emitError('ttl', rsp.message(), rsp.errorCode());
} else {
this.emitError('ttl', `unexpected-response ${rsp.toString()}`);
this.emitError('ttl', rsp.message(), rsp.errorCode());
}
return null;
}
Expand All @@ -781,10 +750,8 @@
return rsp.remainingTtlMillis();
} else if (rsp instanceof CacheItemGetTtl.Miss) {
return null;
} else if (rsp instanceof CacheItemGetTtl.Error) {
this.emitError('ttl', rsp.message(), rsp.errorCode());
} else {
this.emitError('ttl', `unexpected-response ${rsp.toString()}`);
this.emitError('ttl', rsp.message(), rsp.errorCode());
}
return null;
}
Expand Down Expand Up @@ -829,10 +796,8 @@
return 1;
} else if (rsp instanceof CacheUpdateTtl.Miss) {
return 0;
} else if (rsp instanceof CacheUpdateTtl.Error) {
this.emitError('pexpire', rsp.message(), rsp.errorCode());
} else {
this.emitError('pexpire', `unexpected-response ${rsp.toString()}`);
this.emitError('pexpire', rsp.message(), rsp.errorCode());
}
}

Expand All @@ -856,11 +821,8 @@
const rsp = await this.momentoClient.flushCache(this.cacheName);
if (rsp instanceof CacheFlush.Success) {
return 'OK';
} else if (rsp instanceof CacheFlush.Error) {
this.emitError('flushdb', rsp.message(), rsp.errorCode());
return 'OK';
} else {
this.emitError('flushdb', `unexpected-response ${rsp.toString()}`);
this.emitError('flushdb', rsp.message(), rsp.errorCode());
return 'OK';
}
}
Expand Down
Loading