lib/pupa/processor/client.rb in pupa-0.1.4 vs lib/pupa/processor/client.rb in pupa-0.1.5
- old
+ new
@@ -28,13 +28,16 @@
#
# @param [String] cache_dir a directory or a Memcached address
# (e.g. `memcached://localhost:11211`) in which to cache requests
# @param [Integer] expires_in the cache's expiration time in seconds
# @param [Integer] value_max_bytes the maximum Memcached item size
+ # @param [String] memcached_username the Memcached username
+ # @param [String] memcached_password the Memcached password
# @param [String] level the log level
+ # @param [String,IO] logdev the log device
# @return [Faraday::Connection] a configured Faraday HTTP client
- def self.new(cache_dir: nil, expires_in: 86400, value_max_bytes: 1048576, level: 'INFO') # 1 day
+ def self.new(cache_dir: nil, expires_in: 86400, value_max_bytes: 1048576, memcached_username: nil, memcached_password: nil, level: 'INFO', logdev: STDOUT) # 1 day
Faraday.new do |connection|
connection.request :url_encoded
connection.use Middleware::Logger, Logger.new('faraday', level: level)
connection.use Middleware::RaiseError # useful for breaking concurrent requests
@@ -57,10 +60,10 @@
if cache_dir
connection.response :caching do
address = cache_dir[%r{\Amemcached://(.+)\z}, 1]
if address
- ActiveSupport::Cache::MemCacheStore.new(address, expires_in: expires_in, value_max_bytes: Integer(value_max_bytes))
+ ActiveSupport::Cache::MemCacheStore.new(address, expires_in: expires_in, value_max_bytes: Integer(value_max_bytes), username: memcached_username, password: memcached_password)
else
ActiveSupport::Cache::FileStore.new(cache_dir, expires_in: expires_in)
end
end
end