ActiveOrm

Gem Version Build Status

ActiveOrm is a library for object ruby mapping of different databases.

Supported:

  • Redis

Roadmap:

  • Cassandra
  • InfluxDB

Installation

Add this line to your application's Gemfile:

gem 'active_orm'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_orm

Table of Contents

Redis

Configuration:

Options:

  • client: add a custom Redis client

rails generate active_orm:install will generate the following file: ../config/initalizers/active_orm.rb

if defined?(Redis)
  ActiveOrm::Redis.configure do |config|
    config.client = Redis.new(host: '10.0.1.1', port: 6380, db: 15)
  end
end

Usage:

Commands:

  • Geo
  • Hash
  • HyperLogLog
  • Key
  • List
  • PubSub
  • Script
  • Set
  • Sorted Set
  • String
  • Transaction
ActiveOrm::Redis::String.create(:month, '01')
ActiveOrm::Redis::String.find(:month)           #=> '01'
ActiveOrm::Redis::String.evaluate.find(:month)  #=> 1

ActiveOrm::Redis::List.create(:user_1, { id: 32123, name: 'James Dean', username: 'alpha123' })
ActiveOrm::Redis::List.find(:user_1)            #=> { id: '32123', name: 'James Dean', username: 'alpha123' }
ActiveOrm::Redis::List.evaluate.find(:user_1)   #=> { id: 32123, name: 'James Dean', username: 'alpha123' }

Rake:

Options:

  • reset: reset current database
  • reset_all: reset all databases

rake db:redis:reset and rake db:redis:reset_all

Contributing

Your contribution is welcome.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request