Project

active_kv

0.0
No commit activity in last 3 years
No release in over 3 years
Get redis relational
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 4.7.3
~> 10.0

Runtime

>= 0
 Project Readme

ActiveRedis

Installation

Add this line to your application's Gemfile:

gem 'active_kv'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_kv

Usage

Redis server needs to be listen on localhost : default port.

  require "active_redis"

  class Post < ActiveRedis::Base

    keys title: String,
      markdown: String,
      tags: Array,
      source: String

    belongs_to :author

    validates :markdown, presence: true
    validates :title, presence: true

  end

  class Author < ActiveRedis::Base

  keys name: String

  has_many :posts

  end
  • Create new Post
  Post.create title: "Mooo", markdown: "Some stuff"
  • Error messages.
  p = Post.new title: "Moo"
  p.save
  p.errors
  • Handle relations
  a = Author.create name: "Timmy"
  p = Post.create title: "Mooo", markdown: "Some stuff", author_id: 1
  
  a.posts 
  # => Get all posts by author
  
  p.author 
  # => Get author