Project

bindi

0.0
No commit activity in last 3 years
No release in over 3 years
Persist your Ruby objects in Redis.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 0
 Project Readme

Bindi

Persist your Ruby objects to Redis!

Bindi provides a simple Hash-like syntax for serializing and storing Ruby objects using the redis gem. Serialize with Marshal, YAML, JSON or your serializer of choice (as long as it supports #dump and #load methods).

Usage

require 'bindi'

bindi = Bindi.new # Marshal is the default serializer.
#=> #<Redis client v3.0.2 for redis://127.0.0.1:6379/0>
 
bindi[:state_gemstones] = {alabama: 'Star Blue Quartz',
                           alaska: 'Nephrite Jade'}
exit

Your Ruby Object is now stored in Redis:

require 'bindi'

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

bindi[:state_gemstones]
  #=> {:alabama=>"Star Blue Quartz", :alaska=>"Nephrite Jade"}

Additional Hash-like methods:

bindi.keys
 #=> [:state_gemstones]

bindi.key? :nope
 #=> false

bindi.delete :state_gemstones
 #=> {:alabama=>"Star Blue Quartz", :alaska=>"Nephrite Jade"}

bindi.empty?
 #=> true

Alternative Serializers

The default serializer is Marshal but you an alternative serializer can be specified when creating a new Bindi instance:

require 'bindi'
require 'json'

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

A serializer without #dump and #load methods, like Message Pack, can be used by implementing those methods:

require 'bindi'
require 'msgpack'

module MessagePack
  def self.dump(data)
    pack(data)
  end

  def self.load(data)
    unpack(data)
  end
end

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

Installation

Install Bindi

$ gem install bindi

Install Redis

Brew package:

`brew install redis`

Apt-get package:

`sudo apt-get install redis-server`

Or build from source:

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make

Start Redis if it isn't running:

$ redis-server

Contributing

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