Table of Contents

Ruby

We’ve built a small Ruby example using Sinatra here: MemCachier Sinatra Sample App.

Start by adding the dalli gem to your Gemfile. Dalli is a Ruby memcache client.

Then run bundle install:

$ bundle install

You can now start writing some code. First, you’ll need to create a client object with the correct credentials and settings:

The values for MEMCACHIER_SERVERS, MEMCACHIER_USERNAME, and MEMCACHIER_PASSWORD are listed on your cache overview page. Make sure to add them to your environment.

Now you can use the cache through simple get and set operations, as well as many others.

You can also get an insight into your cache usage (number of keys stored and bytes) with the stats command: