Class: Drip::SimpleStore::AtticCache

Inherits:
Object
  • Object
show all
Defined in:
lib/drip.rb

Instance Method Summary collapse

Constructor Details

#initialize(n) ⇒ AtticCache

Returns a new instance of AtticCache.



207
208
209
210
211
# File 'lib/drip.rb', line 207

def initialize(n)
  @size = n
  @tail = 0
  @ary = Array.new(n)
end

Instance Method Details

#push(attic) ⇒ Object



213
214
215
216
217
218
# File 'lib/drip.rb', line 213

def push(attic)
  @ary[@tail].forget if @ary[@tail]
  @ary[@tail] = attic
  @tail = (@tail + 1) % @size
  attic
end