[x] lock would cause a queryable to cache the result of its enumeration; subsequent enumerations would delegate to the cached value, rather than re-execute the network query.
[x] unlock would cause a locked queryable to get rid of its cache, forcing the next enumeration to perform the network query. By default, all queries are in the unlocked state.
Perhaps these would be better named cache and uncache?
Motivation: write a criteria which can be enumerated several times over without needing to re-execute the network query each time, nor for having to throw out context. Useful for providing more data to kaminari.
class Game
field :price, type: Float
scope :cheaper_than, ->( cost ) { lte( price: cost ) }
end
cheap_games = Game.lock.cheaper_than( 10 )
cheap_games.count # => 5
cheap_games.to_a # <#Game price: 5.99> ...
This would help support #8:
lock
would cause a queryable to cache the result of its enumeration; subsequent enumerations would delegate to the cached value, rather than re-execute the network query.unlock
would cause a locked queryable to get rid of its cache, forcing the next enumeration to perform the network query. By default, all queries are in the unlocked state.Perhaps these would be better named
cache
anduncache
?Motivation: write a criteria which can be enumerated several times over without needing to re-execute the network query each time, nor for having to throw out context. Useful for providing more data to kaminari.