English
Fx.lock
About 130 wordsLess than 1 minute
2026-01-09
1. lock uses Redisson's distributed lock, and the unlocking is performed by FxLock.unLock();
Using Redisson's distributed lock, the unlocking operation is performed by FxLock.unLock();
Fx.lock.lockData(<String apiName>, <String dataId>, <Integer expireTime>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| apiName | String | The API name of the object | Y |
| dataId | String | Data ID | Y |
| expireTime | Integer | Expiration time | Y |
Code examples
// Locking must be fine-grained to prevent lock contention waits
FxLock lock = Fx.lock.lockData("Account", "dataId", 2)
// Code section requiring lock protection
// do something
lock.unlock()Notice
- Error example: Using a coarse-grained lock like
lock("prepareData")can negatively impact business operations.- Instead, employ fine-grained locks such as data IDs to lock specific data entries, preventing concurrency issues.
