From e46ce19d249702fccf3b25edfe37559e78d13702 Mon Sep 17 00:00:00 2001 From: Simon Ho Date: Wed, 27 Jul 2016 13:48:06 -0700 Subject: [PATCH] Add KeyValue model --- lib/keyvalue-model.js | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lib/keyvalue-model.js diff --git a/lib/keyvalue-model.js b/lib/keyvalue-model.js new file mode 100644 index 00000000..0bdd7699 --- /dev/null +++ b/lib/keyvalue-model.js @@ -0,0 +1,60 @@ +// Copyright IBM Corp. 2014,2016. All Rights Reserved. +// Node module: loopback +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + +/*! + * Module Dependencies. + */ + +module.exports = KeyValueModel; + +var Model = KeyValueModel; + +function Model(registry) { + this.registry = registry; +} + +// Static + +Model.get = function get(key) { + // ret val by key +} + +Model.expire +Model.expires = function() { + // ret remaining ttl/expires time +} + +Model.delete = +Model.remove = function(key) { + // del val by key +} + +Model.set = function get(key) { + // set val by key +} + +Model.touch = function touch(ttl) { + // renew ttl to given ttl, use now if ttl is not given +} + +// Instance + +Model.prototype.delete = function() { +} + +Model.prototype.get = function() { + // use id from inst to ret latest ver from backend +}; + +Model.prototype.getExpirationTime() { + // return expiration time (UTC timestamp) +}; + +Model.prototype.set = function(ttl) { + // use id from inst and call touch for the instance +}; + +Model.prototype.touch = function() { +};