Does node.js Redis package updating clear the Redis database? - node.js

I've recently updated my node.js Redis package. Now my data seems to be gone. Does updating remove all my data?

it is strange that updating a client library will destroy your data. I suggest looking at the following possible causes:
Redis is not configured to persist data, or your configuration is to persist using RDB snapshots but not frequently enough and you killed Redis the hard way instead of using the SHUTDOWN command.
The client library has some kind of unit test that if run agains an instance does not detect the instance is not empty and will destroy the data content. Did you ran any test?
Make also sure you don't have FLUSHALL / FLUSHDB commands in your code for some reason or that your keys did not simply expired because of a time to live set (with EXPIRE or SETEX or alike).

I do not know much about the Redis client for node, but I can bet on this that the upgrade of a DB client is not causing the clearing of the DB. This would be buggy behavior.
So either this was some kind of bug you run in to or you did something wrong that cleared the DB that is independent to the upgrade of the Redis client you are using.

Related

Need a solution for an Electron application that uses a shared database

I understand that node-mysql can be used for a database with Electron. However, if I build my app, the user will still need MySQL installed on their computer correct? I need a database solution that multiple users of my app can use without having any other dependancies installed. Just my standalone app. Are there any solutions for this?
You can use PouchDB inside your Electron application and set up a remote CouchDB.
PouchDB can work offline inside your application and can synchronize with CouchDB. If you use sync, every time the remote database changes, all connected applications will pull the latest changes to their local database.
Sync will be in two directions (if you want this, otherwise you can use replicate), so when an application makes a database change inside their local PouchDB, it will synchronize this to the remote CouchDB, and all the other applications will also pull this change.
Well, Correct would be to connect your electron app to a remote DB and setup an auth and set up DB behind that. You can also use DB's auth.
or if you can have individual DB per user. You can use Sqlite.

Amazon ElasticCache for Redis with Node.js server

I am using Redis in my Node.js application. I don't use it for caching and I don't want to. I want my data in the Redis to be persistent at any point. Also my every call to redis write to the disk. Is it helpful to use the Amazon elastic cache in such case? Because I understand that Amazon elastic cache handles standby replication and automatic failover which is very important to me. I am running my Node.js server on Amazon EC2. Any help or suggestion would be appreciated.
Currently Amazon ElasticCache's way for keeping a persistent state is through snapshotting which means it uses the Backup and Restore feature to keep a copy in an S3 bucket that you can use for loading your data again in the case of losing it or warming up a new instance.
The backup and restore feature uses BGSAVE in the background, and as a heavy operation on your instance if setup to be done periodically , it is recommended to be running on a read replica.
So to answer your question; I do not think Amazon ElasticCache is a solution for your problem. it was meant for solutions who are looking for a cache layer to scale/speed up lookups for their apps that are running on other storage engines.
Update: As a manually setup alternative (taken from the comments)
If you are opened to setting up your own instance of Redis cluster redis.io/topics/cluster-spec that will be your best bet, it takes care of AFO, and replication, with persistence options enabled as append only file or backing up to RDB files

Can I delete data from my local pouchDB without the delete replicating to couchDB

Is there a way I can clear down the data in my local pouchDB without the changes being replicated to the online couchDB.
I am currently using the db.sync function with live: true
The context for this is I have lots of users entering orders in an offline first environment and would like to cleardown the data every few days to keep the application quick but new lose the orders from couchDB
Unfortunately not, there is a long running open issue for purge # https://github.com/pouchdb/pouchdb/issues/802 which would do what you want, but it has not been implemented yet.
What is your use case, are you doing a 2 way sync and seeing remote updates locally or are you only doing push replication to send the orders? One way to work around this is to periodically create a fresh database locally that only contains the orders you care about.

is there any reason not to install a second instance of MongoDB?

I already have mongoDB on my mac (OS mavericks) because it comes packaged with Meteor. I'm learning some pure, non-Meteor node.js right now. I'd like to work with mongoDB, but I'm afraid to change any of the configuration I've already got on my machine, as I don't want to screw up the Mongo that comes packaged with Meteor.
Is this something I should be concerned about? How do I protect my other mongo instance?
I assume by the MongoDB that comes with Meteor you mean the MongoDB database Meteor uses internally when you type "meteor" and that resides in .meteor inside your app folder. In that case it's no problem adding a MongoDB installation to the OS, they won't conflict.
In fact, I recommend to separately install MongoDB for different reasons. When you are running a production app it's easier to scale, let multiple apps use the same database etc.
First install MongoDB, for example with Homebrew. Then you just run your app with
MONGO_URL=mongodb://127.0.0.1/<db> meteor
According to mongodb's documentation:
...In many cases running multiple instances of mongod on a single system is not recommended but for testing purposes of course possible.
I don't think that meteor has done intensive configuration changes to mongodb's out-of-the-box configuration (except of course if you've done already configuration amendments for special sharding, Oplog tailing strategies etc.)

'Running' Redis with Node

Somewhat trivial question but I feel it would be crucial to get this answered. My question is about Redis and Node; how to 'run' a Redis db and have Node interact with it.
I plan to use node_redis (https://github.com/mranney/node_redis). I am fairly comfortable saying I understand how to use this module to interact with the Redis db.
My questions if one level higher: how and where is the Redis db 'running'? Do I have to install, create and then run/turn on this db before I am able to use node_redis to manipulate it? Or does the act of requiring node_redis already guarantee that there will be a Redis db to interact with?
Asking because my app will run on a device (not a machine) that I know can execute Node because has Node installed but I cannot install Redis on it (or at least I dont know how to) if Node will not be doing it for me.
WHEW I hope that was not too wordy. TIA!
Niko
Redis is a separate program. You have to download it, install, and run separately. If you'll accept default settings (listen port), node_redis with then connect to it automatically as, by default, redis installation has no passphrase set.
You'd just need to call:
var client = require("redis").createClient();
If your requirements are basic (and chances are they are, since you're running it in a limited environment), you might actually use different key-value store, like nStore which is implemented in JS and uses simple files as a storage. This would not require any other program than node itself.

Resources