Skip to content

Commit

Permalink
Allow set/add value to be a number
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbetz committed Nov 19, 2022
1 parent 12b400a commit 1052b2e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/hashpool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default class HashPool extends EventEmitter {
}
}

async set( key: string, value: string, ttl = 0 ): Promise<boolean> {
async set( key: string, value: string|number, ttl = 0 ): Promise<boolean> {
let host;
try {
host = await this.getHost( key );
Expand All @@ -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<boolean> {
async add( key: string, value: string|number, ttl = 0 ): Promise<boolean> {
let host;
try {
host = await this.getHost( key );
Expand Down
6 changes: 3 additions & 3 deletions src/memcached.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
async store( command: string, key: string, value: string|number, ttl = 0 ): Promise<boolean> {
if ( ttl > 60 * 60 * 24 * 30 ) {
// Memcached considers ttls over 30 days to be
// Unix timestamps. This is confusing and usually
Expand All @@ -154,11 +154,11 @@ export default class Memcached extends EventEmitter {
return true;
}

async set( key: string, value: string, ttl = 0 ): Promise<boolean> {
async set( key: string, value: string|number, ttl = 0 ): Promise<boolean> {
return this.store( 'set', key, value, ttl );
}

async add( key: string, value: string, ttl = 0 ): Promise<boolean> {
async add( key: string, value: string|number, ttl = 0 ): Promise<boolean> {
return this.store( 'add', key, value, ttl );
}

Expand Down
4 changes: 2 additions & 2 deletions src/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
async set( key: string, value: string|number, ttl = 0 ): Promise<boolean> {
return this.pool.use( ( client: Memcached ) => client.set( key, value, ttl ) );
}

async add( key: string, value: string, ttl = 0 ): Promise<boolean> {
async add( key: string, value: string|number, ttl = 0 ): Promise<boolean> {
return this.pool.use( ( client: Memcached ) => client.add( key, value, ttl ) );
}

Expand Down

0 comments on commit 1052b2e

Please sign in to comment.