Support
Search this site
Quetzall.com
Home
CloudCache
Sitemap
Recent site activity
REST API
edited by Travis Reeder
Getting Started
edited by Travis Reeder
CloudCache
edited by Travis Reeder
Home
edited by Travis Reeder
CloudCache
edited by Marc Byrd
View All
CloudCache
>
Ruby
>
Getting Started
Using CloudCache with Ruby is very easy.
Install Gem
gem sources -a http://gems.github.com
(you only have to do this once)
gem install activesupport quetzall-cloud_cache
Write Code
To test it out quickly and see how easy it is, let's make a quick test program.
First, create a file called
cctest.rb
Now copy and paste the following code into it:
require 'rubygems'
require 'cloud_cache'
cc = ActiveSupport::Cache::
CloudCache.new(MY_CLOUDCACHE_API_KEY, MY_CLOUDCACHE_SECRET_KEY)
cc.put('coolkey', 'CloudCache is cool')
val = cc.get('coolkey')
puts 'got from cache: ' + val.to_s
Then run it:
ruby
cctest.rb
That's all there is to it.
Other Common Methods
delete(key)
get_multi
Get a batch of items in one shot (improves performance)
list_keys()
Lists all keys in the cache.
flush()
Clears out the cache
my_usage()
Returns your current size usage for your account (in bytes).
increment(key)
increments the value at key
decrement(key)
decrements the value at key
write (synonym for put)
read (synynym for get)
With Ruby on Rails
In environment.rb, do the following:
cc = ActiveSupport::Cache::
CloudCache.new(MY_CLOUDCACHE_API_KEY, MY_CLOUDCACHE_SECRET_KEY)
config.cache_store = cc
Ruby Library Source Code
Comments
_displayNameOrEmail_
- _time_ -
Remove
_text_