@@ -35,6 +35,12 @@ before(function () {
3535 } ) ;
3636} ) ;
3737
38+ beforeEach ( function ( done ) {
39+ redisCache . reset ( function ( ) {
40+ done ( ) ;
41+ } ) ;
42+ } ) ;
43+
3844describe ( 'initialization' , function ( ) {
3945
4046 it ( 'should create a store with password instead of auth_pass (auth_pass is deprecated for redis > 2.5)' , function ( done ) {
@@ -257,6 +263,30 @@ describe('del', function () {
257263 } ) ;
258264 } ) ;
259265
266+ it ( 'should delete multiple values for a given array of keys' , function ( done ) {
267+ redisCache . set ( 'foo' , 'bar' , function ( ) {
268+ redisCache . set ( 'bar' , 'baz' , function ( ) {
269+ redisCache . set ( 'baz' , 'foo' , function ( ) {
270+ redisCache . del ( [ 'foo' , 'bar' , 'baz' ] , function ( err ) {
271+ assert . equal ( err , null ) ;
272+ done ( ) ;
273+ } ) ;
274+ } ) ;
275+ } ) ;
276+ } ) ;
277+ } ) ;
278+
279+ it ( 'should delete multiple values for a given array of keys without callback' , function ( done ) {
280+ redisCache . set ( 'foo' , 'bar' , function ( ) {
281+ redisCache . set ( 'bar' , 'baz' , function ( ) {
282+ redisCache . set ( 'baz' , 'foo' , function ( ) {
283+ redisCache . del ( [ 'foo' , 'bar' , 'baz' ] ) ;
284+ done ( ) ;
285+ } ) ;
286+ } ) ;
287+ } ) ;
288+ } ) ;
289+
260290 it ( 'should return an error if there is an error acquiring a connection' , function ( done ) {
261291 var pool = redisCache . store . _pool ;
262292 sinon . stub ( pool , 'acquireDb' ) . yieldsAsync ( 'Something unexpected' ) ;
@@ -335,22 +365,64 @@ describe('ttl', function () {
335365describe ( 'keys' , function ( ) {
336366 it ( 'should return an array of keys for the given pattern' , function ( done ) {
337367 redisCache . set ( 'foo' , 'bar' , function ( ) {
338- redisCache . keys ( 'f*' , function ( err , arrayOfKeys ) {
339- assert . equal ( err , null ) ;
340- assert . notEqual ( arrayOfKeys , null ) ;
341- assert . notEqual ( arrayOfKeys . indexOf ( 'foo' ) , - 1 ) ;
342- done ( ) ;
368+ redisCache . set ( 'far' , 'boo' , function ( ) {
369+ redisCache . set ( 'faz' , 'bam' , function ( ) {
370+ redisCache . keys ( 'f*' , function ( err , arrayOfKeys ) {
371+ assert . equal ( err , null ) ;
372+ assert . notEqual ( arrayOfKeys , null ) ;
373+ assert . notEqual ( arrayOfKeys . indexOf ( 'foo' ) , - 1 ) ;
374+ assert . equal ( arrayOfKeys . length , 3 ) ;
375+ done ( ) ;
376+ } ) ;
377+ } ) ;
378+ } ) ;
379+ } ) ;
380+ } ) ;
381+
382+ it ( 'should accept a scanCount option' , function ( done ) {
383+ redisCache . set ( 'foo' , 'bar' , function ( ) {
384+ redisCache . set ( 'far' , 'boo' , function ( ) {
385+ redisCache . set ( 'faz' , 'bam' , function ( ) {
386+ redisCache . keys ( 'f*' , { scanCount : 10 } , function ( err , arrayOfKeys ) {
387+ assert . equal ( err , null ) ;
388+ assert . notEqual ( arrayOfKeys , null ) ;
389+ assert . notEqual ( arrayOfKeys . indexOf ( 'foo' ) , - 1 ) ;
390+ assert . equal ( arrayOfKeys . length , 3 ) ;
391+ done ( ) ;
392+ } ) ;
393+ } ) ;
343394 } ) ;
344395 } ) ;
345396 } ) ;
346397
347398 it ( 'should return an array of keys without pattern' , function ( done ) {
348399 redisCache . set ( 'foo' , 'bar' , function ( ) {
349- redisCache . keys ( function ( err , arrayOfKeys ) {
350- assert . equal ( err , null ) ;
351- assert . notEqual ( arrayOfKeys , null ) ;
352- assert . notEqual ( arrayOfKeys . indexOf ( 'foo' ) , - 1 ) ;
353- done ( ) ;
400+ redisCache . set ( 'far' , 'boo' , function ( ) {
401+ redisCache . set ( 'faz' , 'bam' , function ( ) {
402+ redisCache . keys ( function ( err , arrayOfKeys ) {
403+ assert . equal ( err , null ) ;
404+ assert . notEqual ( arrayOfKeys , null ) ;
405+ assert . notEqual ( arrayOfKeys . indexOf ( 'foo' ) , - 1 ) ;
406+ assert . equal ( arrayOfKeys . length , 3 ) ;
407+ done ( ) ;
408+ } ) ;
409+ } ) ;
410+ } ) ;
411+ } ) ;
412+ } ) ;
413+
414+ it ( 'should accept scanCount option without pattern' , function ( done ) {
415+ redisCache . set ( 'foo' , 'bar' , function ( ) {
416+ redisCache . set ( 'far' , 'boo' , function ( ) {
417+ redisCache . set ( 'faz' , 'bam' , function ( ) {
418+ redisCache . keys ( { scanCount : 10 } , function ( err , arrayOfKeys ) {
419+ assert . equal ( err , null ) ;
420+ assert . notEqual ( arrayOfKeys , null ) ;
421+ assert . notEqual ( arrayOfKeys . indexOf ( 'foo' ) , - 1 ) ;
422+ assert . equal ( arrayOfKeys . length , 3 ) ;
423+ done ( ) ;
424+ } ) ;
425+ } ) ;
354426 } ) ;
355427 } ) ;
356428 } ) ;
0 commit comments