Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added get_caches_as_list method

Signed-off-by: Chris Wanstrath <chris@ozmm.org>
  • Loading branch information...
commit 7aa8de6b54ee86da0d10ad59a1b02c0cf466d0b4 1 parent 099c7de
Michael Lovitt lovitt authored committed
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/acts_as_cached/cache_methods.rb
13 lib/acts_as_cached/cache_methods.rb
View
@@ -74,6 +74,19 @@ def get_caches(*args)
(hits.values + missed_records).index_by(&:cache_id)
end
+ # simple wrapper for get_caches that
+ # returns the items as an ordered array
+ def get_caches_as_list(*args)
+ cache_ids = args.last.is_a?(Hash) ? args.first : args
+ cache_ids = [cache_ids].flatten
+ hash = get_caches(*args)
+ list = []
+ cache_ids.size.times do |i|
+ list << hash[cache_ids[i]]
+ end
+ return list
+ end
+
def set_cache(cache_id, value, ttl = nil)
returning(value) do |v|
v = @@nil_sentinel if v.nil?
Please sign in to comment.
Something went wrong with that request. Please try again.