sarkistlt / feathers-redis-cache

Set of Redis caching hooks and routes for feathersjs.
12 stars 19 forks source link

Help with caching a complex query #4

Closed dottodot closed 4 years ago

dottodot commented 4 years ago

I have a query that is like this.

{
  $and: [
    { tags: { $in: ['5d27187cdcfb01b6e35e04fe', '5d2718dddcfb01022b5e0505'] } },
    { product: '5debaed9ee579bdd6036f353' }
  ];
}

however when that is cached it's converted to $and=[object Object],[object Object] which means the same result is returned regardless of the $and query.

I've noticed that if I remove arrayFormat: 'comma' from the stringify options the result looks much better so was wondering if there is a particular reason for this being set as feathers-rest doesn't use it. https://github.com/feathersjs-ecosystem/feathers-rest/blob/master/src/client/base.js

$and[0][tags][$in][0]=5d27187cdcfb01b6e35e04fe&$and[0][tags][$in][1]=5d2718dddcfb01022b5e0505&$and[1][product]=5debaed9ee579bdd6036f353
sarkistlt commented 4 years ago

@dottodot main reason was is to keep cache key as short as possible, but I didn't noticed that it has a bug when stringifying nested array, fixed version is on npm, thanks for the catch.