Bindi

Bindi is a DSL for storing serializable Ruby Objects in Redis using Ohm.

Installation

Add this line to your application's Gemfile:

gem 'bindi'

Or install it yourself:

$ gem install bindi

Then install Redis:

$ brew install redis

And start Redis:

$ redis-server

Usage

The Basics

require 'bindi'
 #=> true

bindi = Bindi.new YAML # Choose between Marshal, YAML, JSON, etcetera for serializing.
#=> #<Redis client v3.0.2 for redis://127.0.0.1:6379/0>

bindi[:state_gemstones] = { alabama: 'Star Blue Quartz',
                            alaska: 'Nephrite Jade', 
                            arizona: 'Turquoise', 
                            arkansas: 'Diamond' }

 #=> {:alabama=>"Star Blue Quartz", ...

exit

Your Ruby Object is now stored in Redis.

require 'bindi'
 #=> true

bindi = Bindi.new YAML
#=> #<Redis client v3.0.2 for redis://127.0.0.1:6379/0>

bindi.keys
 #=> "state_gemstones"

bindi[:state_gemstones]
 #=> #=> {:alabama=>"Star Blue Quartz", ...

Ruby Hash Methods

bindi[:key] = 'value'
 #=> "value"

bindi[:key]
 #=> "value"

bindi.clear # Flushes entire DB

bindi.delete :key
 #=> 1

bindi.each do |key|
  puts key
end

bindi.empty?
 #=> false

bindi.inspect

bindi.key? :nope
 #=> false

bindi.keys
 #=> "key"

Redis Helper Methods

bindi.info
 #=> {"redis_version"=>"2.4.15", ...

bindi.inspect_redis
 #=> "#<Redis client v2.2.2 connected to redis://127.0.0.1:6379 ..."

Contributing

  1. Fork it
  2. Commit your changes
  3. Pull request