Created
September 6, 2012 18:25
-
-
Save jpsilvashy/3659207 to your computer and use it in GitHub Desktop.
Snippets from IronCache blog post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.find(name) | |
@name = name | |
@messages = JSON.parse(settings.ironcache.cache(@name).get('messages').value) | |
Channel.new(@name, @messages) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.find_or_initialize(name) | |
if settings.ironcache.cache(name).get('messages').nil? | |
self.new(name) | |
else | |
self.find(name) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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