Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Abstract interface to data structure servers (Redis for now, Membase, Memcache, and maybe Kestrel later)

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 stash.gemspec


"The sloping companion I cast down the ash, yanked on my tunic and dangled my stash"

Stash provides Ruby-like classes for interacting with data structures servers. Presently the only such server supported is Redis, however support is planned for Membase, Memcache, and possibly Kestrel.

Initializing Stash

Stash supports multiple connections which are initialized through the stash Stash.setup command. Stash operates primarily through the default connection:

Stash.setup :default, :adapter => :redis, :host => 'localhost'

This will connect to the Redis server listening on localhost. Stash.setup takes an options hash with the following parameters:

  • adapter: must be "redis" (mandatory)
  • host: hostname or IP address of the Redis server (mandatory)
  • port: port of the Redis server (optional, default 6379)
  • namespace: Redis namspace to use (optional, default global namespace)
  • password: password to the Redis server (optional)


The core type exposed by Stash is a string. You can store a string in the default Stash using:

Stash[:foobar] = "mystring"

This string can be retrieved as easily as:


And deleted with:

Stash.delete :foobar


Stash supports a mostly ordered list type. You can retrieve a list with:


Stash Lists support most of the methods you'd expect on the Ruby Array type. They are enumerable and support all of Ruby's Enumerable methods.

You can push elements onto the list with:

Stash::List[:baz] << 'asdf'

And pop them with:


Lists can be converted to arrays with:


Or iterated with:

Stash::List[:baz].each { |elem| ... }

Stash asks you to think of lists as being somewhat loosely ordered. This means that Stash will make its best effort to give you a list in order, however that order may shift around depending on how the backend storage system is implemented. Distributed systems may have interesting properties.


Stash hashes work like Ruby hashes. You can retrieve a Stash::Hash with:


You can set members of a Stash::Hash with:

Stash::Hash[:qux][:omgwtf] == "bbq"

or retrieve them with:


You can convert a Stash::Hash to a Ruby hash with:

Something went wrong with that request. Please try again.