I've never seen this lambda version of the cache key. The Rails collection cache code is quite easy to read. This is the line from github that gets your lambda - and if you don't provide one, they create a default one!
I usually create a wrapper object that implements a cache_key method to do the key generation. It also is then used inside the partial, so it's a little more noticable when you use data that isn't part of the cache key
For your case, you can do more in here for a complicated case
I've had object IDs and 4-5 booleans or enums in my cache key before now. Having 30 possible variants is still better than having 1 per user (unless you have only 30 users, in which case you may have optimized too soon)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I've never seen this lambda version of the cache key. The Rails collection cache code is quite easy to read. This is the line from github that gets your lambda - and if you don't provide one, they create a default one!
github.com/rails/rails/blob/b378bd...
I usually create a wrapper object that implements a
cache_key
method to do the key generation. It also is then used inside the partial, so it's a little more noticable when you use data that isn't part of the cache keyFor your case, you can do more in here for a complicated case
I've had object IDs and 4-5 booleans or enums in my cache key before now. Having 30 possible variants is still better than having 1 per user (unless you have only 30 users, in which case you may have optimized too soon)