nest
Version, currently 0.1.01 version
- 0.1.0latestDec 3, 2016
github.com/soveran/nest-crystal
Object Oriented Keys for Redis
Installation
# Add this to your shard.yml
dependencies:
nest:
github: soveran/nest-crystal
version: ~> 0.1.0Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- MIT
- Author
- Michel Martens
Dependencies
Runtime Dependencies
- resp*github: soveran/resp-crystal, branch: master
Development Dependencies
- crotest*github: emancu/crotestdev
README
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.
require "resp"
resp = Resp.new("redis://localhost:6379")
resp.call("SADD", "event:3:attendees", "Albert")
resp.call("SMEMBERS", "event:3:attendees") #=> ["Albert"]
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:
require "nest"
resp = Resp.new("redis://localhost:6379")
event = Nest.new("event", resp)
event[3][:attendees].call("SADD", "Albert")
event[3][:attendees].call("SMEMBERS") #=> ["Albert"]
You can also create the Nest instance without passing a Resp
client, and just provide it when invoking the call method:
require "nest"
resp = Resp.new("redis://localhost:6379")
event = Nest.new("event")
event[3][:attendees].call(resp, "SADD", "Albert")
event[3][:attendees].call(resp, "SMEMBERS") #=> ["Albert"]
Usage
To create a new namespace:
ns = Nest.new("foo")
ns.to_s #=> "foo"
ns["bar"].to_s #=> "foo:bar"
ns["bar"]["baz"]["qux"].to_s #=> "foo:bar:baz:qux"
And you can use any object as a key, not only strings:
ns[:bar][42].to_s #=> "foo:bar:42"
In a more realistic tone, lets assume you are working with Redis and dealing with events:
events = Nest.new("events", resp)
id = events[:id].call("INCR")
events[id][:attendees].call("SADD", "Albert")
meetup = events[id]
meetup[:attendees].call("SMEMBERS") #=> ["Albert"]
Nest allows you to execute all the Redis commands that expect a key as the first parameter.
Installation
Add this to your application's shard.yml:
dependencies:
nest:
github: soveran/nest-crystal
branch: master
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- Dec 3, 2016
- Commit
4c69711d2160- Indexed
- yes
Dependents
Repository
github.com/soveran/nest-crystal
Metadata
- Created
- Aug 12, 2026
- Updated
- Sep 26, 2026
- Synced
- Sep 26, 2026
- Versions
- 1