All Projects → soveran → Nest

soveran / Nest

Licence: mit
Generate nested namespaced keys for key-value databases.

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Nest

Redisclient
Java Redis Client GUI Tool
Stars: ✭ 2,254 (+1098.94%)
Mutual labels:  redis
Redisc
A Go redis cluster client built on top of redigo.
Stars: ✭ 183 (-2.66%)
Mutual labels:  redis
Grbac
权限管理服务平台, 利用shiro权限管理设计思想, 支持单用户多角色,比RBAC的资源管理更细粒度化
Stars: ✭ 186 (-1.06%)
Mutual labels:  redis
Ts App
Boilerplate project for a TypeScript API (Express, tsoa) + UI (React/TSX)
Stars: ✭ 182 (-3.19%)
Mutual labels:  redis
Weibospider
This is a sina weibo spider built by scrapy [微博爬虫/持续维护]
Stars: ✭ 2,408 (+1180.85%)
Mutual labels:  redis
Destiny.core.flow
Destiny.Core.Flow是基于.Net Core,VUE前后分离,开发的一个开源Admin管理框架目前有以下模块:菜单管理、用户管理、角色管理、用户角色、角色权限等功能。
Stars: ✭ 184 (-2.13%)
Mutual labels:  redis
Ninja Mutex
Mutex implementation for PHP
Stars: ✭ 180 (-4.26%)
Mutual labels:  redis
Springcloud Miaosha
一个基于spring cloud Greenwich的简单秒杀电子商城项目,适合新人阅读。A simple spring cloud based seckill shopping mall project, suitable for young people to read. It can be used as a paper material for academic defense.
Stars: ✭ 187 (-0.53%)
Mutual labels:  redis
Mage2vuestorefront
Magento to Vue-storefront datapump - synchronizes Products, Categories and Product-to-category links between your Magento2 API and NoSQL database of vue-storefront
Stars: ✭ 183 (-2.66%)
Mutual labels:  redis
Ebook Chat App Spring Websocket Cassandra Redis Rabbitmq
Pro Java Clustering and Scalability: Building Real-Time Apps with Spring, Cassandra, Redis, WebSocket and RabbitMQ
Stars: ✭ 186 (-1.06%)
Mutual labels:  redis
Ioredis Mock
Emulates ioredis by performing all operations in-memory.
Stars: ✭ 181 (-3.72%)
Mutual labels:  redis
Phpfastcache
A high-performance backend cache system. It is intended for use in speeding up dynamic web applications by alleviating database load. Well implemented, it can drops the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful.
Stars: ✭ 2,171 (+1054.79%)
Mutual labels:  redis
Hospital
医院预约挂号微信小程序(Spring Boot、Vue、Uni-app)
Stars: ✭ 182 (-3.19%)
Mutual labels:  redis
Spring Data Examples
Examples for using Spring Data for JPA, MongoDB, Neo4j, Redis
Stars: ✭ 181 (-3.72%)
Mutual labels:  redis
Lua Resty Redis Connector
Connection utilities for lua-resty-redis
Stars: ✭ 186 (-1.06%)
Mutual labels:  redis
Fullstack Boilerplate
Fullstack boilerplate using Typescript, React, GraphQL
Stars: ✭ 181 (-3.72%)
Mutual labels:  redis
Interview Comment
Stars: ✭ 182 (-3.19%)
Mutual labels:  redis
Blog Service
blog service @nestjs
Stars: ✭ 188 (+0%)
Mutual labels:  redis
Springboot Learning
《Spring Boot基础教程》,2.x版本持续连载中!点击下方链接直达教程目录!
Stars: ✭ 13,916 (+7302.13%)
Mutual labels:  redis
Ms
🔥MS 是一个前后分离的分布式 spring cloud 框架(全家桶),这里有统一认证,统一网关等等功能,是一个非常简洁的微服务脚手架
Stars: ✭ 186 (-1.06%)
Mutual labels:  redis

Nest

Object Oriented Keys for Redis.

Description

If you are familiar with databases like Redis and libraries like Ohm you already know how important it is to craft the keys that will hold the data.

>> redis = Redic.new
>> redis.call("HSET", "Event:3", "name", "Redis Meetup")
>> redis.call("HGET", "Event:3", "name")
=> ["Redis Meetup"]

It is a design pattern in key-value databases to use the key to simulate structure, and you can read more about this in the case study for a Twitter clone.

Nest helps you generate those keys by providing chainable namespaces that are already connected to Redis:

>> event = Nest.new("Event")
>> event[3].call("HSET", "name", "Redis Meetup")
>> event[3].call("HGET", "name")
=> ["Redis Meetup"]

Alternatively, you can send the Redis commands as messages to Nest, and if the method definition is missing it will forward the command to Redis:

>> event = Nest.new("Event")
>> event[3].hset("name", "Redis Meetup")
>> event[3].hget("name")
=> ["Redis Meetup"]

Usage

To create a new namespace:

>> ns = Nest.new("foo")
=> "foo"

>> ns["bar"]
=> "foo:bar"

>> ns["bar"]["baz"]["qux"]
=> "foo:bar:baz:qux"

And you can use any object as a key, not only strings:

>> ns[:bar][42]
=> "foo:bar:42"

In a more realistic tone, lets assume you are working with Redis and dealing with events:

>> event = Nest.new("Event")
=> "Event"

>> id = event[:id].incr
=> 1

>> event[id].hset("name", "Redis Meetup")
=> 1

>> meetup = event[id]
=> "Event:1"

>> meetup.hget("name")
=> ["Redis Meetup"]

API

call: Receives a Redis command and its arguments, and returns the reply from the Redis server. If the reply from Redis is an error, an instance of RuntimeError is returned.

call!: Similar to call, but instead of returning an instance of RuntimeError when the command fails, the error is raised.

queue: Receives the same kind of arguments as call, but enqueues the command in a transaction.

commit: Commits the transaction and returns the reply from Redis.

Any call to a missing method will result in Nest converting the method name to a Redis command and applying the arguments in an invocation to call.

For example:

ns = Nest.new("foo")
ns.append("hello,")
ns.append(" world")
ns.get

Is equivalent to:

ns = Nest.new("foo")
ns.call("APPEND", "hello,")
ns.call("APPEND", " world")
ns.call("GET")

Supplying your existing Redis instance

You can supply a Redic instance as a second parameter. If you don't, a default instance is created for you:

>> redis = Redic.new("redis://localhost:6379")
=> #<Redic:0x007fa640845f10 ...>

>> event = Nest.new("Event", redis)
=> "Event"

>> event[:id].call("TYPE")
=> "string"

Nest objects respond to redis and return a Redic instance. It is automatically reused when you create a new namespace, and you can reuse it when creating a new instance of Nest:

>> event = Nest.new("Event", meetup.redis)
=> "Event"

Nest allows you to execute all the Redis commands that expect a key as the first parameter. If you use any other command, the result can be unexpected.

Differences with redis-namespace

redis-namespace wraps Redis and translates the keys back and forth transparently.

Use redis-namespace when you want all your application keys to live in a different scope.

Use Nest when you want to use the keys to represent structure.

Tip: instead of using redis-namespace, it is recommended that you run a different instance of redis-server. Translating keys back and forth is not only delicate, but unnecessary and counterproductive.

Differences with Ohm

Ohm lets you map Ruby objects to Redis with little effort. It not only alleviates you from the pain of generating keys for each object, but also helps you when dealing with references between objects.

Use Ohm when you want to use Redis as your database.

Use Nest when mapping objects with Ohm is not possible or overkill.

Tip: Ohm uses Nest internally to deal with keys. Having a good knowledge of Nest will let you extend Ohm to suit your needs.

Installation

$ gem install nest
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].