Suor / django-cacheops

A slick ORM cache with automatic granular event-driven invalidation.
BSD 3-Clause "New" or "Revised" License
2.09k stars 227 forks source link

user_script error in insideout mode #480

Open ProvoloneStein opened 1 month ago

ProvoloneStein commented 1 month ago

Hi! I am using insideout mode. In search filters I often get the error "user_script:12: too many results to unpack script" in lua script. I noticed that for none tag filters dnfs is too big. For example, in the testcase dnfs_to_schemes produces a list with 2^n elements. If we add another nested field for search, the number of keys increases dramatically. I think more complex optimization at "tree to dnfs" may be needed here, but btw added qfix for this error

Suor commented 1 month ago

Thanks for pointing this out, your test, however, does not fail for me even on the old code. The number of items allowed to be unpacked might be dependent on Redis version though.

I looked into it and your thought about dnfs() being the source also was fruitful. I've changed it's code to use set[frozenset[tuple]] for intermediate DNFs instead of list[list[tuple]] and it should do the trick. Might be marginally slower though. The code is here #481, will require some lower level unit tests I guess.