https://github.com/squarecloudofc/redis-map
A simple way to use something similar to the Map in JavaScript, but synchronized with the power of Redis.
https://github.com/squarecloudofc/redis-map
javascript redis squarecloud
Last synced: 4 months ago
JSON representation
A simple way to use something similar to the Map in JavaScript, but synchronized with the power of Redis.
- Host: GitHub
- URL: https://github.com/squarecloudofc/redis-map
- Owner: squarecloudofc
- License: apache-2.0
- Created: 2023-10-13T02:38:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-13T02:46:49.000Z (over 2 years ago)
- Last Synced: 2025-06-12T08:43:45.321Z (about 1 year ago)
- Topics: javascript, redis, squarecloud
- Language: JavaScript
- Homepage: https://npmjs.com/@squarecloudofc/redis-map
- Size: 8.79 KB
- Stars: 9
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Information
A simple way to use something similar to the Map in javascript, but synchronized with the power of Redis.
## Install
```
npm install @squarecloudofc/redis-map
```
## Example of usage
```javascript
const { RedisAPI, RedisMap } = require("@squarecloudofc/redis-map");
(async () => {
const connections = await new RedisAPI({
url: process.env.REDIS,
monitor: (type, message) => {
console.log(`[REDIS] ${type}: ${message}`);
}
}).connect();
// Example using same connection (for two maps);
// first map;
const cacheUsers = new RedisMap({
connections,
name: "example:cache:users",
monitor: (type, message, name) => {
console.log(name, type, message);
}
});
// second map;
const cacheApps = new RedisMap({
connections,
name: "example:cache:apps",
sync: false // disable sync with redis;
});
await cacheUsers.set("joao", { plan: "free", balance: 1000 });
console.log(cacheUsers.get("joao"), "\n");
await cacheApps.set("water_man", { protection: 10, shield: 50 });
console.log(cacheApps.get("water_man"), "\n");
connections.disconnect();
})();
```
## LICENSE
This project is licensed under the Apache License 2.0.
Sponsored by [Square Cloud](https://squarecloud.app/).