The local storage used to store items on the node.
- constructor
- methods
Creates a new Storage instance.
const plexus = require("plexus");
const storage = new plexus.Storage();
key
: String The key of the item to look for.
Checks if an item with the specified key is already stored.
// Is an item with the key "key" already stored
storage.has("key");
key
: String The key of the item to look for.
Returns the item with the specified key.
// Get the item with the key "key" from the storage
storage.get("key");
key
: String The key of the item used to retrieve it.value
: Object The data to store in the item.republish
: Boolean (Default: false) Whether or not the item should be republished after it expires.
Stores an item on the node.
const item = new plexus.Item({key: "key", value: "data", publisher: "id", timestamp: 0});
// Store an item that wont be republished after it expires
storage.set("key", item, false);
key
: String The key of the item to delete.
Removes an item from the node.
// Remove the item with the key "key" from the storage
storage.delete("key");
Returns the list of items to republish after expiration.
// Get the items to republish
const items = storage.get_republishable_items();
Returns the list of items stored.
// Get the items stored
const items = storage.get_items();