Sha256: c5af5d5194d6d70e82935ea446fc43add7a80f0b37d4b26b11c3966bd45c3354

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

module KewegoParty
  module Cache

    def app_reset_app_token
      with_caching(app_token_cache_key, :cache => 0, :period => 0) do
        app_get_token
      end
    end

    def app_token
      self.app_token = with_caching(app_token_cache_key, :cache => app_token_cache_timeout, :period => 0) do
        app_get_token
      end
      @app_token
    end

    def app_token=(token)
      @app_token = token
    end

    protected
    def with_caching(key, options)
      APICache.get(key, options) do
        yield
      end
    rescue APICache::TimeoutError => err
      raise KewegoParty::TimeoutException.new
    end

    def app_token_cache_key
      'app_get_token'
    end

    def app_token_cache_timeout
      22 * 3600
    end

    def cache_fail
      raise
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kewego_party-0.0.1 lib/kewego_party/cache.rb