Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redijson_models

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redijson_models

  • 0.9.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

RediJsonModels

Document-like ORM based on Redis key value store - uses Redis Re-JSON for full json manipulation

Install

Add to your gemfile:

gem 'redijson_models', '~> 0.8.1'

Or without bundler, run in your shell:

gem i redijson_models

Requirements

  • Redis (v4+)
  • Re-JSON module installed

DB API

Model.get 1 #=> returns an object instance (gets it from redis)

Model.all #=> returns an array of Model object instances

Model.create({}) #=> creates an entry in redis

Model.update(1, {}) #=> updates a record in redis

Model Definition and Instance API by Virtus

Definition:
class Document
  extend  RediJsonModelLib
  include RediJsonModelMixin
  include Virtus.model

  attribute :id,        Integer
  attribute :name,      String
  attribute :contents,  String

  def antani
    # "..."
  end
end

Instance API:

doc = Document.new name: "Foo", contents: "Bar123"
puts doc.name      #=> "foo"
puts doc.antani    #=> "..."
doc.save # saves the record, gives an auto increment id (example: 1)

doc = Document.get doc.id
puts doc.name      #=> "foo"
puts doc.antani    #=> "..."

Run local Redis (+ Re-JSON module) locally via Docker:

in this repo run:

docker-compose up

Which use the docker-compose.yml to start your redis.

Set up your Redis and RJSON

# sample environment setup
require 'bundler'
Bundler.require :default

# setup redis
R = Redis.new 

# load and configure redis with rejson models
include RediJsonModels
RJ.configure redis: R

class Document
  # ...
end

Run specs

(you need to run a local redis + rejson service - explained above)

Run:

rake spec

Enjoy!

@makevoid

FAQs

Package last updated on 17 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc