lib/twitter_friendly/cache.rb in twitter_friendly-0.2.0 vs lib/twitter_friendly/cache.rb in twitter_friendly-0.2.1
- old
+ new
@@ -5,14 +5,14 @@
class Cache
extend Forwardable
def_delegators :@client, :clear, :cleanup
def initialize(*args)
- options = args.extract_options!
+ options = {expires_in: 1.hour, race_condition_ttl: 5.minutes}.merge(args.extract_options!)
path = options[:cache_dir] || File.join('.twitter_friendly', 'cache')
FileUtils.mkdir_p(path) unless File.exists?(path)
- @client = ::ActiveSupport::Cache::FileStore.new(path, expires_in: 1.hour, race_condition_ttl: 5.minutes)
+ @client = ::ActiveSupport::Cache::FileStore.new(path, options)
end
def fetch(method, user, options = {}, &block)
key = CacheKey.gen(method, user, options.except(:args))
super_operation = options[:args].length >= 2 && options[:args][1][:super_operation]