Skip to content

Instantly share code, notes, and snippets.

@defsprite
Created August 18, 2013 22:14
Show Gist options
  • Save defsprite/6264304 to your computer and use it in GitHub Desktop.
Save defsprite/6264304 to your computer and use it in GitHub Desktop.
class SimpleHashRingBuffer < Hash
def initialize(max_keys = 4096)
@max_keys = max_keys - 1
end
def []=(key, value)
if self.size > @max_keys
self.shift
end
super
end
alias :store :[]=
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment