chanzuckerberg / redis-memo

A Redis-based version addressable caching system. Memoize pure functions, aggregated database queries, and 3rd party API calls.
https://rubygems.org/gems/redis-memo
MIT License
33 stars 3 forks source link

[feature] enable caching on queries with NOT #62

Closed Dingying0410 closed 3 years ago

Dingying0410 commented 3 years ago

Summary

This PR enables queries with that has both NOT and other bound queries.

Previously we decided to not to cache any queries with NOT, however, queries with both NOT and other bound queries can be cached. E.g

Site.where(a: 1).where.not(b: 1) can be cached based on a as dependency 
Site.where.not(b: 1) should not be cached

My current approach is to return bind_params when we parse a notequal statement, so that

Test plan

rspec

codecov[bot] commented 3 years ago

Codecov Report

Merging #62 (56c39e2) into main (8492ded) will increase coverage by 0.05%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #62      +/-   ##
==========================================
+ Coverage   97.31%   97.37%   +0.05%     
==========================================
  Files          34       34              
  Lines        2125     2283     +158     
==========================================
+ Hits         2068     2223     +155     
- Misses         57       60       +3     
Impacted Files Coverage Δ
lib/redis_memo/memoize_query/cached_select.rb 93.33% <100.00%> (-0.70%) :arrow_down:
spec/memoize_query_spec.rb 100.00% <100.00%> (ø)
lib/redis_memo/middleware.rb 27.27% <0.00%> (-6.07%) :arrow_down:
lib/redis_memo.rb 97.05% <0.00%> (ø)
lib/redis_memo/memoizable/invalidation.rb 100.00% <0.00%> (ø)
lib/redis_memo/memoize_query.rb 97.95% <0.00%> (+0.90%) :arrow_up:
spec/cache_spec.rb 98.03% <0.00%> (+1.02%) :arrow_up:
lib/redis_memo/cache.rb 100.00% <0.00%> (+1.78%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8492ded...56c39e2. Read the comment docs.