Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't drop method without arguments #165

Closed
KeKs0r opened this issue Jun 16, 2016 · 2 comments
Closed

Can't drop method without arguments #165

KeKs0r opened this issue Jun 16, 2016 · 2 comments
Assignees
Labels
bug
Milestone

Comments

@KeKs0r
Copy link

@KeKs0r KeKs0r commented Jun 16, 2016

Hi,
I am trying to drop a method that has no arguments.

If that is the case the id is an empty string. Which is not an issue for policy.set:

   const id = (key && typeof key === 'object') ? key.id : key;
    this._cache.set({ segment: this._segment, id: id }, value, ttl, (err) => {

https://github.com/hapijs/catbox/blob/master/lib/policy.js#L237-L238

But if I want to invalidate the same, I get an Error:

    const id = (key && typeof key === 'object') ? key.id : key;
    if (!id) {
        return callback(new Error('Invalid key'));
    }

    this._cache.drop({ segment: this._segment, id: id }, (err) => {

https://github.com/hapijs/catbox/blob/master/lib/policy.js#L257-L262

Is it possible to remove the id check?

@KeKs0r

This comment has been minimized.

Copy link
Author

@KeKs0r KeKs0r commented Jun 16, 2016

I found a workaround which solves it. Just generate a static key:

        server.method('getCurrentGames', getCurrentGames, {
            bind: server,
            cache: {
                cache: 'redis',
                expiresIn: 1000 * 60 * 3,
                staleIn: 1000 * 60,
                staleTimeout: 10000,
                generateTimeout: 1000 * 5
            },
            generateKey: function (array) {
                return 'main';
            }
        });

I still think its not consistent, that set allows it, but not drop.

@hueniverse hueniverse added the bug label Jun 20, 2016
tsuz added a commit to tsuz/catbox that referenced this issue Mar 2, 2017
tsuz added a commit to tsuz/catbox that referenced this issue Mar 2, 2017
@tsuz

This comment has been minimized.

Copy link

@tsuz tsuz commented Mar 2, 2017

Hi @hueniverse

I couldn't find the contribution guide and made a PR for this bug. Let me know if it requires any more detail!

@hueniverse hueniverse self-assigned this May 27, 2017
@hueniverse hueniverse added this to the 7.1.4 milestone May 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.