Skip to content

Commit

Permalink
fix: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bruuuuuuuce committed Oct 13, 2021
1 parent b60ccdf commit abd00eb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Momento.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
import {Status} from '@grpc/grpc-js/build/src/constants';
import {cacheServiceErrorMapper} from './CacheServiceErrorMapper';
import {ChannelCredentials, Interceptor} from '@grpc/grpc-js';
import {DeleteCacheResponse} from './messages/DeleteCacheResponse';
import {CreateCacheResponse} from './messages/CreateCacheResponse';

interface Claims {
/**
Expand Down Expand Up @@ -96,14 +98,14 @@ export class Momento {
/**
* creates a new cache in your Momento account
* @param {string} name - cache name to create
* @returns Promise<void>
* @returns Promise<CreateCacheResponse>
*/
public createCache(name: string): Promise<void> {
public createCache(name: string): Promise<CreateCacheResponse> {
this.validateCacheName(name);
const request = new control.control_client.CreateCacheRequest({
cache_name: name,
});
return new Promise<void>((resolve, reject) => {
return new Promise<CreateCacheResponse>((resolve, reject) => {
this.client.CreateCache(
request,
{interceptors: this.interceptors},
Expand All @@ -119,7 +121,7 @@ export class Momento {
reject(cacheServiceErrorMapper(err));
}
} else {
resolve();
resolve(new CreateCacheResponse());
}
}
);
Expand All @@ -129,13 +131,13 @@ export class Momento {
/**
* deletes a cache and all of the items within it
* @param {string} name - name of cache to delete
* @returns Promise<void>
* @returns Promise<DeleteCacheResponse>
*/
public deleteCache(name: string): Promise<void> {
public deleteCache(name: string): Promise<DeleteCacheResponse> {
const request = new control.control_client.DeleteCacheRequest({
cache_name: name,
});
return new Promise<void>((resolve, reject) => {
return new Promise<DeleteCacheResponse>((resolve, reject) => {
this.client.DeleteCache(
request,
{interceptors: this.interceptors},
Expand All @@ -151,7 +153,7 @@ export class Momento {
reject(cacheServiceErrorMapper(err));
}
} else {
resolve();
resolve(new DeleteCacheResponse());
}
}
);
Expand Down
4 changes: 4 additions & 0 deletions src/MomentoCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export class MomentoCache {
return cache;
}

/**
* temporary work around to allow for users to create a cache, and then immediately call get/set on it
* @private
*/
private async waitForCacheReady(): Promise<void> {
const key = '00000';
const maxWaitDuration = 5000;
Expand Down
1 change: 1 addition & 0 deletions src/messages/CreateCacheResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class CreateCacheResponse {}
1 change: 1 addition & 0 deletions src/messages/DeleteCacheResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class DeleteCacheResponse {}

0 comments on commit abd00eb

Please sign in to comment.