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


latest commit f0de64c58c
Tony Arcieri authored December 13, 2010
Octocat-spinner-32 lib Use a thread per request (at least until a connection pool can be imp… December 07, 2010
Octocat-spinner-32 spec Hash support November 23, 2010
Octocat-spinner-32 .document Initial commit to stash. October 30, 2010
Octocat-spinner-32 .gitignore Update to RSpec 2.1 November 22, 2010
Octocat-spinner-32 LICENSE Initial commit to stash. October 30, 2010
Octocat-spinner-32 README.markdown loltypo December 13, 2010
Octocat-spinner-32 Rakefile Update to RSpec 2.2.0 December 07, 2010
Octocat-spinner-32 VERSION Version bump to 1.0.0 December 07, 2010
Octocat-spinner-32 stash.gemspec Update gemspec December 07, 2010


"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.