Skip to content

Cache expire patterns #13

@sidinwillis

Description

@sidinwillis

Hi, thank you for sharing!

I think there's a paranthesis here put in the wrong place:

const patterns = keysPattern.split(',').map(
     pattern => pattern.endsWith('*') ? pattern : [pattern, pattern + DATA_POSTFIX]) //<--here
    .reduce((acc, item) =>
    {           
        acc.push(...item)
        return acc          
    }, [])

If the pattern is

*/test*

the reduce would make this an array of char.

The first character (*) is then passed to getkeys, deleting the entire database.

I fixed it in this way

const patterns = keysPattern.split(',').map(
     pattern => pattern.endsWith('*') ? pattern : [pattern, pattern + DATA_POSTFIX]
    .reduce((acc, item) =>
    {           
        acc.push(...item)
        return acc          
    }, [])) <--here

I wrong something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions