@rbxts/muon
v1.0.7
Published
A memory store library
Maintainers
Readme
⚛️ Muon
Muon is a simple memory store library implementation designed with ease of use in mind. It features exponential backoff for every operation in Hash Maps, Queues, and Sorted Maps
📦 Installation
To install Muon, use npm:
npm install @rbxts/muon🧪 Usage
import { Muon } from '@rbxts/muon';
const hashMap = Muon.hashMap('myHashMap', {
lifetime: 60, // data only exists for 60 seconds
exponentialBackoff = {
base: 1.5; // if something fails, it will retry for 1.5 (1.5^1), then 2.25 (1.5^2), ..., and so on till maxTries has been reached
maxTries: 5; // a maximum of 5 tries before it gives an error
}
});
(async() => {
await hashMap.set('count', 1);
await hashMap.update('count', (oldCount) => ++oldCount); // increments the count. has a side effect of resetting the lifetime of the count
print(await hashMap.get<number>('count'));
})();Any operation method has an overrideOptions parameter, which allows you to specify what options should be used for the operation
// ...
await hashMap.set('count', 1, { lifetime: 120 }); // use a lifetime of 120 seconds🤝 Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
📄 License
Muon is licensed under the MIT License. See the LICENSE file for more details.
