This repository was archived by the owner on Feb 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Storages
August (Chris) edited this page Sep 10, 2019
·
1 revision
To create a storage, you must extend the
Storage
structure.
// myStorage.js
const { Storage } = require('laffey');
module.exports = class MyStorage extends Storage {
constructor() {
super('storage');
}
add(pkt) {
// required to add the "user" packet
}
remove(pkt) {
// required to remove the "user" packet
}
};
// instance.js
const { Instance } = require('laffey');
const Storage = require('path/to/my/storage/file');
const i = new Instance({ storage: new Storage() });
Comes with Laffey pre-built
The memory storage is with an Collection of voters but refreshes when the server restarts or disconnects.
new Instance({
storage: new MemoryStorage({
// name (optional): The name of the Collection
name: 'awau'
})
});
Comes with Laffey pre-built
The redis storage is more optimized in performance and not much heavy as the
Memory Storage
You must have an redis server prebuilt or it'll not work.
new Instance({
storage: new RedisStorage({
// port (required): The port to use from Redis
port: 6379,
// host (optional): The host to connect to (default: 'localhost')
host: 'localhost'
})
});