Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/julien-r44/verrou
๐ Verrou is a library for managing Locks in Node.js. Support multiple drivers
https://github.com/julien-r44/verrou
lock mutex mysql nodejs postgres redis
Last synced: 11 days ago
JSON representation
๐ Verrou is a library for managing Locks in Node.js. Support multiple drivers
- Host: GitHub
- URL: https://github.com/julien-r44/verrou
- Owner: Julien-R44
- License: mit
- Created: 2023-12-27T23:28:21.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-05-03T06:46:29.000Z (6 months ago)
- Last Synced: 2024-05-03T12:20:42.718Z (6 months ago)
- Topics: lock, mutex, mysql, nodejs, postgres, redis
- Language: TypeScript
- Homepage: https://verrou.dev
- Size: 2.24 MB
- Stars: 148
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
![banner](./assets/banner.png)
Verrou ๐ is a locking library for Node.js applications
## Features
- ๐ Easy usage
- ๐ Multiple drivers (Redis, Postgres, MySQL, Sqlite, In-Memory and others)
- ๐ฆ Multiple database adapters ( Knex, Kysely ... )
- ๐ Customizable named locks
- ๐ Consistent API across all drivers
- ๐งช Easy testing by switching to an in-memory driver
- ๐จ Easily extensible with your own driversSee documentation at [verrou.dev](https://verrou.dev/docs/introduction)
## Why Verrou ?
Main advantage of Verrou is that it provides a consistent API across all drivers. This means that you can switch from one driver to another without having to change your code. It also means you can switch to an in-memory in your test environment, making tests faster and easier to setup (no infrastructure or anything fancy to setup).
Having a consistent API also means that you don't have to learn a new API when switching from one driver to another. Today, in the node ecosystem, we have different npm packages to manage locks, but they all have differents APIs and behaviors.
But having a consistent API doesn't mean having a less powerful API. Verrou provides every features you would expect from a locking library, and even more.
## Basic usage
```ts
import { Verrou } from '@verrou/core'
import { redisStore } from '@verrou/core/drivers/redis'
import { memoryStore } from '@verrou/core/drivers/memory'const verrou = new Verrou({
default: 'redis',
stores: {
redis: { driver: redisStore() },
memory: { driver: memoryStore() }
}
})// Lock a resource and run a function
await verrou.createLock('my-resource').run(async () => {
await doSomething()
}) // Lock is automatically released
```## Sponsors
If you like this project, [please consider supporting it by sponsoring it](https://github.com/sponsors/Julien-R44/). It will help a lot to maintain and improve it. Thanks a lot !
![](https://github.com/julien-r44/static/blob/main/sponsorkit/sponsors.png?raw=true)