Meteor Redis



Experimental Redis support is available on Atmosphere

Experiments with Redis

back in Devshop May 2014
by Justin Santa Barbara


On Atmosphere

About Redis

In-memory key-value data store
(with on-disk persistence)

Strings, Hashes, Sets, Ordered Sets, Lists, etc...

Ideas


  • Translate MongoDB operations to Redis
    • minimize the efforts of porting a mongo-based app
    • difficult to map mongo queries to redis
    • users still use the mongo api

  • Go with direct Redis support
    • same api as redis
    • miniredis!
    • clear performance win

Miniredis

In-memory data-structure in JavaScript to mimic Redis API



Used as a cache for the browser clients and provides latency compensation opportunity (since api is the same)

Redis-livedata


  • Gets update from the Redis server (key-space not.)
  • Pushes them to the clients based on subscriptions
  • Provides the ObserveChanges API
  • Deals with allow/deny rules
  • Implements the latency compensation
  • Proxies local look-ups to Miniredis
Blaze - #each
^
observe | changes
|
Miniredis  -> app code                                 
^
               | - DDP
v
                          PubSub (appcode)
                                           | - observeChanges
                                 Redis-Livedata  - app code
^
|
Redis

Common Keys pattern

  • users::1::firstName - John
  • users::1::lastName - Doe
  • users::2::firstName - Jane
  • users::2::lastName - Doe

Redis.matching("users::1::*")
returns everything related to first user

  • fetch
  • observeChanges

What works

  • Strings
  • Hashes
  • Latency compensation
  • ObserveChanges
  • #each in Blaze
  • Allow/deny
  • pub/sub
  • autopublish

What doesn't




  • Big Hashes
  • Sets, lists, etc
  • Accounts (need mongo)

Community FeedbacK

GitHub/Meteor/Redis-Livedata
GitHub/Meteor/Miniredis             
Made with Slides.com