Skip to content

Instantly share code, notes, and snippets.

@steffentchr
Created January 30, 2010 19:07
Show Gist options
  • Save steffentchr/290681 to your computer and use it in GitHub Desktop.
Save steffentchr/290681 to your computer and use it in GitHub Desktop.
var module = 'bomber-auth';
var path = '/tmp';
var ps = new PersistentStore(path);
// PersistentStore.set(namespace, document_name, object);
var user = {user_id:1234, name:'Guan Yang', email:'[email protected]'};
ps.set(module, 'user1234', user);
// PersistentStore.get(namespace, document_name, [default={}]);
var saved_user = ps.get(module, 'user1234');
sys.puts(saved_user.name);
--> Guan Yang
// PersistentStore.unset(namespace, document_name);
ps.unset(module, 'user1234');
var user = ps.get(module, 'user');
--> throw error
var PersistentStore = exports.PersistentStore = function(path) {
this.storage_path = path || this.DEFAULT_STORAGE_PATH;
}
PersistentStore.DEFAULT_STORAGE_PATH;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment