Git Product home page Git Product logo

redpear's Introduction

Redpear

<img src=“https://travis-ci.org/bsm/redpear.png?branch=master” alt=“Build Status” />

A simple, elegant & efficient ORM for Redis, optimised for speed!

Redis is a simple key/value store, hence storing structured data can be a challenge. Redpear allows you to store/find/associate “records” in a Redis DB very efficiently, minimising IO operations and storage space where possible.

Examples

class Post < Redpear::Model
  column :title
  column :body
end

class Comment < Redpear::Model
  column :body
  index :post_id
end

Let’s create a post and a comment:

post = Post.new :title => "Hi!", :body => "I'm a new post"
post.id # => 100, automatically persisted
comment = Comment.new :post_id => post.id, :body => "I like this!"
comment.id # => 200

Now let’s find and update a Comment:

comment = Comment.find 200
comment.body = "This is fun!"

Under the hood:

Redis.current.keys
# => [ "posts:[~]",   # => Set { 1 } - stores the primary keys of all posts
#      "posts:[+]",   # => Counter value: "100" - stores last primary key value
#      "posts:100",   # => Hash { title: "Hi!", body: "I'm a new post" }
#      "comments:[~]" # => Set, as above, just for comments
#      "comments:[+]" # => Counter, as above, just for comments
#      "comments:200" # => Hash { post_id: 100, body: "I like this!" }
#      "comments:[post_id]:100" # => Set { 200 } - lookup for comments that
#                               # belong to post #100
#    ]

Installation

You should be familiar with gembundler.com/. Simply include redpear in your Gemfile:

gem "redpear"

You can additionally include the hiredis extension (written in C), you you want to make use of it:

gem "hiredis", "~> 0.3.1"
gem "redis", "~> 2.2.0", :require => ["redis/connection/hiredis", "redis"]

Please see github.com/pietern/hiredis-rb for more details.

Highlights

Redpear is VERY lightweight. Compared with other ORMs, it offers raw speed at the expense of convenience.

  • Uses the latest Redis features

  • Minimises number of IO operations

  • Minimises storage space (memory)

  • Thread-safe

  • “Lazy” where possible/reasonable

LICENSE

Copyright (c) 2011-2013 Black Square Media

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

redpear's People

Contributors

dim avatar dolzenko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.