@@ -6,10 +6,10 @@ const redis = require('../redis/redis-client');
66const { logPipelineFailures } = redis ;
77const REDIS_ACTIVITY_KEY_PREFIX = config . get ( 'redis.keyPrefix' ) ;
88
9- const scanExistingCasesKeys = ( f ) => {
9+ const scanExistingCasesKeys = ( f , prefix ) => {
1010 const stream = redis . scanStream ( {
1111 // only returns keys following the pattern
12- match : `${ REDIS_ACTIVITY_KEY_PREFIX } case :*` ,
12+ match : `${ REDIS_ACTIVITY_KEY_PREFIX } ${ prefix } :*` ,
1313 // returns approximately 100 elements per call
1414 count : 100 ,
1515 } ) ;
@@ -26,7 +26,7 @@ const scanExistingCasesKeys = (f) => {
2626 } ) ;
2727} ;
2828
29- const getCasesWithActivities = ( f ) => scanExistingCasesKeys ( f ) ;
29+ const getCasesWithActivities = ( f , prefix ) => scanExistingCasesKeys ( f , prefix ) ;
3030
3131const cleanupActivitiesCommand = ( key ) => [ 'zremrangebyscore' , key , '-inf' , Date . now ( ) ] ;
3232
@@ -38,6 +38,11 @@ const pipeline = (cases) => {
3838
3939const storeCleanup = ( ) => {
4040 debug ( 'store cleanup starting...' ) ;
41+ cleanCasesWithPrefix ( 'case' ) ; // Cases via RESTful interface.
42+ cleanCasesWithPrefix ( 'c' ) ; // Cases via socket interface.
43+ } ;
44+
45+ const cleanCasesWithPrefix = ( prefix ) => {
4146 getCasesWithActivities ( ( cases ) => {
4247 // scan returns the prefixed keys. Remove them since the redis client will add it back
4348 const casesWithoutPrefix = cases . map ( ( k ) => k . replace ( REDIS_ACTIVITY_KEY_PREFIX , '' ) ) ;
@@ -48,7 +53,7 @@ const storeCleanup = () => {
4853 . catch ( ( err ) => {
4954 debug ( 'Error in getCasesWithActivities' , err . message ) ;
5055 } ) ;
51- } ) ;
56+ } , prefix ) ;
5257} ;
5358
5459exports . start = ( crontab ) => {
0 commit comments