https://github.com/adorsys/lock-persistence
https://github.com/adorsys/lock-persistence
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/adorsys/lock-persistence
- Owner: adorsys
- Created: 2018-02-01T14:28:34.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-25T06:54:32.000Z (over 6 years ago)
- Last Synced: 2025-01-01T02:19:57.821Z (9 months ago)
- Language: Java
- Size: 36.1 KB
- Stars: 0
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lock-persistence
## Usage in spring boot
1. Add maven dependency:
```
de.adorsys.lock-persistence
lock-persistence-core
${lock-persistence.version}
```### ... for relational databases
2. Add maven dependency:
```
de.adorsys.lock-persistence
lock-persistence-jpa
${lock-persistence.version}
```3. Add `@EnableJpaLockPersistence` annotation to your spring boot configuration class
4. Make sure your database contains following table definition named `lock_persistence` within default schema:
```
CREATE TABLE lock_persistence (
id SERIAL PRIMARY KEY,
name VARCHAR(256),
value VARCHAR(36),
expires TIMESTAMP
);
```(example for postgres)
continue with 5.
### ... for mongo
2. Add maven dependency:
```
de.adorsys.lock-persistence
lock-persistence-mongo
${lock-persistence.version}
```3. Add `@EnableMongoLockPersistence` annotation to your spring boot configuration class
continue with 5.
### provide and use LockClient Bean
5. Make sure you're providing a Bean for a `LockClient` instance:
```
@Bean
LockClient lockClient(LockService lockService) {
return new SimpleLockClient("", lockService);
}
```6. Use the injected `LockClient` instance in your code:
```
lockClient.executeIfOwned("", new Runnable() {
@Override
public void run() {
... your stuff to be locked for concurrent access ...
}
});
```