import { RedisClient } from 'redis' ; const OTC_ORDER_NONCE_BUCKET_COUNTER_KEY = 'otcorder.nonce.bucket.counter' ; export class CacheClient { constructor ( private readonly _redisClient ) { } public async closeAsync ( ) { return new Promise ( ( resolve , reject ) => { this . _redisClient . quit ( ( err ) => { if ( err ) { reject ( err ) ; } resolve ( ) ; } ) ; } ) ; } public async getNextOtcOrderBucketAsync ( ) { return new Promise ( ( resolve , reject ) => { this . _redisClient . incr ( OTC_ORDER_NONCE_BUCKET_COUNTER_KEY , ( err , valueAfterIncr ) => { if ( err ) { reject ( err ) ; } resolve ( valueAfterIncr ) ; } ) ; } ) ; } }