Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

-

  • Loading branch information...
commit 77eec5ece9f1140ee1ff07d28a6d743487ccbf66 1 parent 098149a
@JoeHitchens JoeHitchens authored
Showing with 41 additions and 5 deletions.
  1. +0 −2  README
  2. 0  docroot/rpc.js
  3. +41 −3 index.js
View
2  README
@@ -1,8 +1,6 @@
-
This module sponsored by [Sleepless Inc. (sleepless.com)](http://sleepless.com/)
This will hopefully have a common interface for the
"least common denominator" functions of each db soon.
-
View
0  docroot/rpc.js
No changes.
View
44 index.js
@@ -1,9 +1,47 @@
-global.mongodb = require("mongodb")
-global.redis = require("redis")
-global.ds = require("ds")
+//var mongodb = require("mongodb")
+//var redis = require("redis")
+var log = require("log5").mkLog("db:")
+log(5)
+var dirty = false;
+
+var ds = new require("ds").DS()
+
+function set(cb, k, v, ttl) {
+ ttl = ttl || 0
+ ds[k] = v
+ dirty = true
+ cb( null )
+}
+function get(cb, k) {
+ var v = ds[k]
+ cb( ds[k] );
+}
+
+function del(cb, k) {
+ delete ds[k]
+ dirty = true;
+}
+
+var api = {
+ set: set,
+ get: get,
+ del: del,
+}
+
+var rpc = require("rpc")
+rpc.createServer(api).listen(12345)
+rpc.log(5)
+
+setInterval(function tick() {
+ if(dirty) {
+ ds.save();
+ dirty = false;
+ }
+}, 5*1000)
+
Please sign in to comment.
Something went wrong with that request. Please try again.