Class Rufus::Verbs::ConditionalEndPoint

  1. lib/rufus/verbs/conditional.rb

An EndPoint with a cache for conditional GETs.

ep = ConditionalEndPoint.new(
  :host => "restful.server",
  :port => 7080,
  :resource => "inventory/tools")

res = ep.get :id => 1
  # first call will retrieve the representation completely

res = ep.get :id => 1
  # the server (provided that it supports conditional GET) only
  # returned a 304 answer, the response is returned from the
  # ConditionalEndPoint cache

The :cache_size option allows to set the size of the conditional GET cache. The default size is currently 147.

Methods

public class

  1. new

public instance

  1. cache_current_size
  2. cache_size

Public class methods

new (opts)
[show source]
    # File lib/rufus/verbs/conditional.rb, line 52
52:     def initialize (opts)
53: 
54:       super
55: 
56:       cs = opts[:cache_size] || 147
57: 
58:       @cache = LruHash.new cs
59:     end

Public instance methods

cache_current_size ()

Returns the count of representation ‘cached’ here for the purpose of conditional GET requests.

[show source]
    # File lib/rufus/verbs/conditional.rb, line 65
65:     def cache_current_size
66: 
67:       @cache.size
68:     end
cache_size ()

Returns the max size of the conditional GET cache.

[show source]
    # File lib/rufus/verbs/conditional.rb, line 73
73:     def cache_size
74: 
75:       @cache.maxsize
76:     end