Redis adapter for jugglingdb
Redis adapter for jugglingdb.
To use it you need
var Schema = require'jugglingbd'Schema;var schema = 'redis';
Make sure you have redis server running on default port, then run
Be careful, it could delete your data in database number 0
Enabling this feature allows to keep only "hot" data in redis and unload rarely used data to backyard.
Backyard is an additional storage that used by redis adapter to mirror all data. Data in redis has some expiration period when mirrored in backyard database. When expired data requested from redis (actual record is not present), then record loaded from backyard and restored in redis. Each time record requested expiration timeout renewed.
backyard section using the same format as normal schema
settings definition in
exportsdevelopment =main:driver: 'redis-hq'database: 1log: truebackyard:driver: 'mysql'username: 'root'database: 'myapp'log: true;
expire setting for model in db/schema.js:
dbdefine'Comment'mproperty'text' String;mset'expire' 30; // expire record in 30 seconds;
This setting may be also set to -1 to disable expiration.
Use your models as usual. All data where
expire is not set to -1 will be mirrored
automatically and restored in redis db when requested after expiration.
Please note that you will get an additional error messages from backyard database. Expiration only being set when both redis and backyard db responded with success to prevent data loss.
Hint 1. If you are using
compoundjs and some sql adapter as backyard for redis,
app.enable('autoupdate'); setting is useful to not care about schema (at
least in development env).
Hint 2. Use
log: true to debug sql queries.
Hint 3. Make sure your schema is sql-friendly. The most often bottleneck is indexes length, specify
length attribute for each indexed String property.