Commit 86b7103c authored by sergio1990's avatar sergio1990

Basic caching subsystem config

parent cf0a2629
......@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_dependency "colorize", "0.7.2"
spec.add_dependency "colorize", ">= 0.7.2"
spec.add_dependency "active_redis", "0.0.9"
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake", ">= 10.3.0"
......
......@@ -14,7 +14,9 @@ module BetfairApiNgRails
:locale,
:formatter,
:keep_alive_session,
:keep_alive_url
:keep_alive_url,
:use_cache,
:cache_expire
def formatter=(value)
@formatter = BetfairApiNgRails::Api::FormatterFactory.initialize_formatter value
......
......@@ -8,6 +8,7 @@ module BetfairApiNgRails
provider.fetch method: method, params: hashing(params)
end
include Api::ConnectionExt::Caching
include Api::ConnectionExt::Logging
include Api::ConnectionExt::ErrorHandling
include Api::ConnectionExt::SsoidRefreshing
......
require 'active_support/inflector'
module BetfairApiNgRails
module Api
module ConnectionExt
module Caching
include BetfairApiNgRails::Api::Constants
def self.included(base)
base.send :class_eval, <<-CODE
def request_with_caching(method, params = {})
res = request_without_caching(method, params)
end
alias_method :request_without_caching, :request
alias_method :request, :request_with_caching
CODE
end
private
end
end
end
end
\ No newline at end of file
......@@ -9,4 +9,8 @@ BetfairApiNgRails.config do |config|
config.formatter = nil
config.keep_alive_session = true
# Caching settings
config.use_cache = false
config.cache_expire = 5 # in seconds
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment