Permalink
Browse files

added dirtydb support

  • Loading branch information...
1 parent 241ff19 commit d5f89012e734aa1af629e2ac2c6a45a7d489f592 @Pita committed Aug 11, 2011
Showing with 64 additions and 0 deletions.
  1. +1 −0 benchmark.js
  2. +61 −0 dirty_db.js
  3. +1 −0 package.json
  4. +1 −0 randomAccessTest.js
View
@@ -39,6 +39,7 @@ var valueMap = {};
var bench_settings = {};
bench_settings["mysql"] = {"user":"etherpadlite", host: "localhost", "password":"etherpadlite", database: "etherpadlite"};
bench_settings["sqlite"] = {filename:"var/sqlite3.db"};
+bench_settings["dirty"] = {filename:"var/dirty.db"};
if(process.argv.length == 3)
{
View
@@ -0,0 +1,61 @@
+/**
+ * 2011 Peter 'Pita' Martischka
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS-IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var dirty = require("dirty");
+var async = require("async");
+
+exports.database = function(settings)
+{
+ this.db=null;
+
+ if(!settings || !settings.filename)
+ {
+ settings = {filename:null};
+ }
+
+ this.settings = settings;
+
+ //set default settings
+ this.settings.cache = 0;
+ this.settings.writeInterval = 0;
+ this.settings.json = false;
+}
+
+exports.database.prototype.init = function(callback)
+{
+ this.db = new dirty(this.settings.filename);
+ callback();
+}
+
+exports.database.prototype.get = function (key, callback)
+{
+ callback(null, this.db.get(key));
+}
+
+exports.database.prototype.set = function (key, value, callback)
+{
+ this.db.set(key,value,callback);
+}
+
+exports.database.prototype.remove = function (key, callback)
+{
+ this.db.rm(key,callback);
+}
+
+exports.database.prototype.close = function(callback)
+{
+ callback();
+}
View
@@ -7,6 +7,7 @@
"dependencies" : {
"mysql" : "0.9.2",
"sqlite3" : "2.0.15",
+ "dirty" : "0.9.2",
"async" : "0.1.9",
"channels": "0.0.2"
},
View
@@ -32,6 +32,7 @@ var localDB = {};
var bench_settings = {};
bench_settings["mysql"] = {"user":"etherpadlite", host: "localhost", "password":"etherpadlite", database: "etherpadlite"};
bench_settings["sqlite"] = {filename:"var/sqlite3.db"};
+bench_settings["dirty"] = {filename:"var/dirty.db"};
if(process.argv.length == 3)
{

0 comments on commit d5f8901

Please sign in to comment.