From 1052b2e887cf54e59bde771bcacae8d4f5709149 Mon Sep 17 00:00:00 2001 From: Josh Betz Date: Sat, 19 Nov 2022 12:22:07 -0600 Subject: [PATCH] Allow set/add value to be a number --- package.json | 2 +- src/hashpool.ts | 4 ++-- src/memcached.ts | 6 +++--- src/pool.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 9b58416..837d68e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@joshbetz/memcached", - "version": "1.0.0", + "version": "1.0.1", "description": "", "main": "build/index.js", "types": "build/index.d.ts", diff --git a/src/hashpool.ts b/src/hashpool.ts index c28e29a..c1d8b49 100644 --- a/src/hashpool.ts +++ b/src/hashpool.ts @@ -160,7 +160,7 @@ export default class HashPool extends EventEmitter { } } - async set( key: string, value: string, ttl = 0 ): Promise { + async set( key: string, value: string|number, ttl = 0 ): Promise { let host; try { host = await this.getHost( key ); @@ -171,7 +171,7 @@ export default class HashPool extends EventEmitter { return host.set( key, value, ttl ); } - async add( key: string, value: string, ttl = 0 ): Promise { + async add( key: string, value: string|number, ttl = 0 ): Promise { let host; try { host = await this.getHost( key ); diff --git a/src/memcached.ts b/src/memcached.ts index 3102cea..4b9a5bc 100644 --- a/src/memcached.ts +++ b/src/memcached.ts @@ -135,7 +135,7 @@ export default class Memcached extends EventEmitter { return this.command( 'flush_all' ); } - async store( command: string, key: string, value: string, ttl = 0 ): Promise { + async store( command: string, key: string, value: string|number, ttl = 0 ): Promise { if ( ttl > 60 * 60 * 24 * 30 ) { // Memcached considers ttls over 30 days to be // Unix timestamps. This is confusing and usually @@ -154,11 +154,11 @@ export default class Memcached extends EventEmitter { return true; } - async set( key: string, value: string, ttl = 0 ): Promise { + async set( key: string, value: string|number, ttl = 0 ): Promise { return this.store( 'set', key, value, ttl ); } - async add( key: string, value: string, ttl = 0 ): Promise { + async add( key: string, value: string|number, ttl = 0 ): Promise { return this.store( 'add', key, value, ttl ); } diff --git a/src/pool.ts b/src/pool.ts index 42a626c..b3422d5 100644 --- a/src/pool.ts +++ b/src/pool.ts @@ -63,11 +63,11 @@ export default class Pool extends EventEmitter { return this.pool.use( ( client: Memcached ) => client.flush() ); } - async set( key: string, value: string, ttl = 0 ): Promise { + async set( key: string, value: string|number, ttl = 0 ): Promise { return this.pool.use( ( client: Memcached ) => client.set( key, value, ttl ) ); } - async add( key: string, value: string, ttl = 0 ): Promise { + async add( key: string, value: string|number, ttl = 0 ): Promise { return this.pool.use( ( client: Memcached ) => client.add( key, value, ttl ) ); }