Skip to content

Instantly share code, notes, and snippets.

@jpsilvashy
Created September 6, 2012 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpsilvashy/3659207 to your computer and use it in GitHub Desktop.
Save jpsilvashy/3659207 to your computer and use it in GitHub Desktop.
Snippets from IronCache blog post
def self.find(name)
@name = name
@messages = JSON.parse(settings.ironcache.cache(@name).get('messages').value)
Channel.new(@name, @messages)
end
def self.find_or_initialize(name)
if settings.ironcache.cache(name).get('messages').nil?
self.new(name)
else
self.find(name)
end
end
# Inserts a new message into the channel
def insert(message)
self.messages.push message
self.messages = self.messages.last(settings.channel_message_limit)
self.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment