IronCache

This add-on is operated by Iron.io

Elastic, scalable, highly available, secure cloud-based key/value store.

IronCache

Last Updated: 19 March 2014

Table of Contents

IronCache is an elastic, scalable, highly available, persistent and secure cloud based key/value store. IronCache grows with you on demand, doesn’t evict items (they only expire), and ensures you’ll never need to rebuild your cache. It’s great for persistent and reliable incrementors/counters, and can be accessed through an easy to use REST interface or memcached interface. Used it for short term persistence and long term storage without worrying about losing data.

You also have full visibility into your caches and usage with the Iron.io user interface:

Cache List

Getting started

It’s quick and easy to get IronCache set up and running on Heroku; you just need to install the IronCache addon. You can do this with the heroku command:

$ heroku addons:add iron_cache:developer
-----> Adding iron_cache to cold-winter-5462... done, v10 (free)

This will add the developer level addon for IronCache, which will let you test the add-on and play around a bit.

There are other levels of the addon, as well. We recommend you upgrade before you use IronCache in production.

Configuration

IronCache has clients for a lot of languages, and you can always use the REST API (or write your own!). This means your existing Heroku stack should work without any changes.

Ruby

First, install the Ruby gem:

$ gem install iron_cache
Fetching: iron_cache-1.4.0.gem (100%)
Successfully installed iron_cache-1.4.0

If you’re building for a Rails application or anything that uses Bundler, add the following to your Gemfile:

gem 'iron_cache'

Ruby usage

This is for the Ruby client, but all clients have the same operations. See the docs for your particular language.

require 'iron_cache'

# Create an IronCache::Client object
@ironcache = IronCache::Client.new

# Get a cache (if it doesn't exist, it will be created when you first post an item
@cache = @ironcache.cache("my_cache")

# Put an item
@cache.put("mykey", "hello world!")

# Get an item
item = @cache.get("mykey")
p item.value

# Delete an item
item.delete # or @cache.delete("mykey")

# Increment an item in the cache
item = @cache.increment("mycounter", 1)
p item

Python

Install with pip/easy_install

iron_cache_python is available in the Python Package Index as “iron_cache”. This means you can run pip install iron_cache or easy_install iron_cache from your command line to download iron_cache_python and all its dependencies.

Install from source

You can also download the source from Github. Once you have the source, you can run python setup.py install from the directory containing the source code to install iron_cache_python.

Note: You will need the iron_core_python module for iron_cache_python to function.

Python usage

from iron_cache import *

# Create an client object
cache = IronCache()

# Put an item
cache.put(cache="test_cache", key="mykey", value="Hello IronCache!")

# Get an item
item = cache.get(cache="test_cache", key="mykey")
print item.value

# Delete an item
cache.delete(cache="test_cache", key="mykey")

# Increment an item in the cache
cache.increment(cache="test_cache", key="mykey", amount=10)

PHP

Install

Download iron_cache.phar from from Github and require it in your code:

<?php
require_once "phar://iron_cache.phar";

PHP usage

<?php
require_once "phar://iron_cache.phar";

# Create a client object
$cache = new IronCache();
$cache->setCacheName('my_cache');

# Put an item
$cache->put("mykey", "hello world!");

# Get an item
$item = $cache->get("mykey");
echo $item->value

# Delete a message (you must delete a message when you're done with it or it will go back on the queue after a timeout
$cache->delete("mykey");

# Increment an item in the cache
$cache->increment("mykey", 1);

Next steps

You can find full documentation at the Iron.io Dev Center.

Support

Issues should get logged with Heroku Support. You’re also welcome to stop by the Iron.io support chat room and chat with Iron.io staff about issues. You can also find more resources at the Iron.io Dev Center.