Sha256: 46bf2314d5e9939ffd1a31552a40a0b00741f28762289a803012c670b7aab006
Contents?: true
Size: 881 Bytes
Versions: 3
Compression:
Stored size: 881 Bytes
Contents
require 'booking_locations/version' require 'booking_locations/api' require 'booking_locations/slot' require 'booking_locations/location' require 'active_support/core_ext/module/attribute_accessors' require 'active_support/cache/null_store' module BookingLocations DEFAULT_PREFIX = 'booking_locations:'.freeze DEFAULT_TTL = 2 * 60 * 60 # 2 hours mattr_writer :api mattr_writer :cache def self.api @@api ||= BookingLocations::Api.new end def self.cache @@cache ||= ActiveSupport::Cache::NullStore.new end def self.find(id, expires = DEFAULT_TTL) cache.fetch(cache_prefix(id), expires_in: expires) do api.get(id) do |response_hash| Location.new(response_hash) end end end def self.clear_cache cache.delete_matched(cache_prefix('*')) end def self.cache_prefix(key) DEFAULT_PREFIX.dup.concat(key) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
booking_locations-0.15.0 | lib/booking_locations.rb |
booking_locations-0.14.0 | lib/booking_locations.rb |
booking_locations-0.13.0 | lib/booking_locations.rb |