Skip to content

Commit 1986999

Browse files
committed
Remove old callback handling code
1 parent d1fbeea commit 1986999

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

_src/lib/node_cache.coffee

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ module.exports = class NodeCache extends EventEmitter
9292
# myCache.get "myKey", ( err, val )
9393
#
9494
get: ( key )=>
95-
9695
# handle invalid key types
9796
if (err = @_isInvalidKey( key ))?
9897
throw err
@@ -158,7 +157,7 @@ module.exports = class NodeCache extends EventEmitter
158157
#
159158
# myCache.set "myKey", "my_String Value"
160159
#
161-
# myCache.set "myKey", "my_String Value", "10"
160+
# myCache.set "myKey", "my_String Value", 10
162161
#
163162
set: ( key, value, ttl )=>
164163
# check if cache is overflowing
@@ -170,8 +169,8 @@ module.exports = class NodeCache extends EventEmitter
170169
if @options.forceString and not typeof value is "string"
171170
value = JSON.stringify( value )
172171

173-
# remap the arguments if `ttl` is not passed
174-
if arguments.length is 3 and typeof ttl is "function"
172+
# set default ttl if not passed
173+
unless ttl?
175174
ttl = @options.stdTTL
176175

177176
# handle invalid key types
@@ -264,7 +263,7 @@ module.exports = class NodeCache extends EventEmitter
264263
#
265264
# myCache.del( "myKey" )
266265
#
267-
del: ( keys, cb )=>
266+
del: ( keys )=>
268267
# convert keys to an array of itself
269268
if not Array.isArray( keys )
270269
keys = [ keys ]
@@ -311,14 +310,7 @@ module.exports = class NodeCache extends EventEmitter
311310
#
312311
# myCache.ttl( "myKey", 1000 )
313312
#
314-
ttl: =>
315-
# change args if only key and callback are passed
316-
[ key, args... ] = arguments
317-
for arg in args
318-
switch typeof arg
319-
when "number" then ttl = arg
320-
when "function" then cb = arg
321-
313+
ttl: (key, ttl) =>
322314
ttl or= @options.stdTTL
323315
if not key
324316
return false
@@ -327,7 +319,7 @@ module.exports = class NodeCache extends EventEmitter
327319
if (err = @_isInvalidKey( key ))?
328320
throw err
329321

330-
# check for existant data and update the ttl value
322+
# check for existent data and update the ttl value
331323
if @data[ key ]? and @_check( key, @data[ key ] )
332324
# if ttl < 0 delete the key. otherwise reset the value
333325
if ttl >= 0
@@ -357,7 +349,7 @@ module.exports = class NodeCache extends EventEmitter
357349
#
358350
# myCache.getTtl( "myKey" )
359351
#
360-
getTtl: ( key, cb )=>
352+
getTtl: ( key )=>
361353
if not key
362354
return undefined
363355

0 commit comments

Comments
 (0)