Class: Arrest::IdentityCache

Inherits:
Object
  • Object
show all
Defined in:
lib/arrest/transport/request_context.rb

Instance Method Summary collapse

Constructor Details

#initializeIdentityCache

Returns a new instance of IdentityCache.



15
16
17
# File 'lib/arrest/transport/request_context.rb', line 15

def initialize()
  @map = {}
end

Instance Method Details

#flushObject



35
36
37
# File 'lib/arrest/transport/request_context.rb', line 35

def flush()
  @map.clear
end

#lookup(id, &blk) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/arrest/transport/request_context.rb', line 19

def lookup(id, &blk)
  hit = @map[id]
  unless hit
    hit = @map[id] = yield
  end
  hit.clone
end

#remove(id) ⇒ Object



31
32
33
# File 'lib/arrest/transport/request_context.rb', line 31

def remove(id)
  @map.delete(id)
end

#update(id, object) ⇒ Object



27
28
29
# File 'lib/arrest/transport/request_context.rb', line 27

def update(id, object)
  @map[id] = object
end