pixl-server-storage 3.1.2 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -626,16 +626,18 @@ Then configure your storage thusly:
626
626
  "engine": "SQLite",
627
627
  "SQLite": {
628
628
  "base_dir": "data",
629
- "filename": "sqlite.db"
629
+ "filename": "sqlite.db",
630
+ "pragmas": {
631
+ "auto_vacuum": 0,
632
+ "cache_size": -100000
633
+ }
630
634
  }
631
635
  }
632
636
  ```
633
637
 
634
- The `base_dir` defaults to the current working directory, and will be created on startup if necessary.
635
-
636
- The optional `keyPrefix` property works similarly to the [S3 Key Prefix](#s3-key-prefix) feature. It allows you to prefix all the SQLite keys with a common string, to separate your application's data in a shared database situation.
638
+ The `base_dir` defaults to the current working directory, and will be created on startup if necessary. The `filename` is the name of the SQLite DB file on disk (also created if necessary).
637
639
 
638
- The optional `keyTemplate` property works similarly to the [S3 Key Template](#s3-key-template) feature. It allows you to specify an exact layout of MD5 hash characters, which can be prefixed, mixed in with or postfixed after the key.
640
+ The optional `pragmas` object allows you set one or more [SQLite Pragmas](https://www.sqlite.org/pragma.html#toc) (configuration settings) on the database at startup. Here you can specify things such as [auto_vacuum](https://www.sqlite.org/pragma.html#pragma_auto_vacuum) and [cache_size](https://www.sqlite.org/pragma.html#pragma_cache_size), among many others.
639
641
 
640
642
  ## Hybrid
641
643
 
package/engines/SQLite.js CHANGED
@@ -62,6 +62,18 @@ module.exports = Class.create({
62
62
  self.db = new SQLite3.Database( db_file, callback );
63
63
  },
64
64
  function(callback) {
65
+ // optionally set pragmas on the db
66
+ if (!sql_config.pragmas) return process.nextTick(callback);
67
+ async.eachSeries( Object.keys(sql_config.pragmas),
68
+ function(key, callback) {
69
+ var value = sql_config.pragmas[key];
70
+ self.db.run(`PRAGMA ${key} = ${value};`, callback);
71
+ },
72
+ callback
73
+ ); // eachSeries
74
+ },
75
+ function(callback) {
76
+ // create our table if necessary
65
77
  self.db.run( 'CREATE TABLE IF NOT EXISTS items( key TEXT PRIMARY KEY, value BLOB, modified INTEGER )', callback );
66
78
  },
67
79
  function(callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixl-server-storage",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "description": "A key/value/list storage component for the pixl-server framework.",
5
5
  "author": "Joseph Huckaby <jhuckaby@gmail.com>",
6
6
  "homepage": "https://github.com/jhuckaby/pixl-server-storage",
package/test/config.json CHANGED
@@ -67,7 +67,11 @@
67
67
  },
68
68
  "SQLite": {
69
69
  "base_dir": "data",
70
- "filename": "sqlite.db"
70
+ "filename": "sqlite.db",
71
+ "pragmas": {
72
+ "auto_vacuum": 0,
73
+ "cache_size": -100000
74
+ }
71
75
  }
72
76
  }
73
77
  }