Interface BootCache
- All Known Implementing Classes:
BootCache_RedisImple
public interface BootCache
- Author:
- Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleandefault longflashsaleAcquireQuota(String itemId, long requestAmount) flash sale - order competition before reducing inventorydefault voidflashsaleEnable(String itemId, boolean isEnabled) flash sale - enabledefault booleanflashsaleInventoryInit(String itemId, long totalAmount, long limit) flash sale - init inventorydefault FlashSaleflashsaleInventoryReport(String itemId) flash sale - inventory reportdefault longflashsaleRevokeQuota(String itemId, long requestAmount) flash sale - revoke an order (undo order competition, normally happens when failed to pay within N minutes)default StringbooleantryLock(String lockName, String unlockPassword, long ttlToExpireIncaseUnableToUnlock, TimeUnit timeUnit) this is a Distributed non-blocking version of lock() method; it attempts to acquire the lock immediately, return true if locking succeedsbooleanunlocks the Distributed Lock instance
-
Method Details
-
tryLock
boolean tryLock(String lockName, String unlockPassword, long ttlToExpireIncaseUnableToUnlock, TimeUnit timeUnit) this is a Distributed non-blocking version of lock() method; it attempts to acquire the lock immediately, return true if locking succeeds- Parameters:
lockName- the name of the tryLockunlockPassword- unlockPassword is to be used for unlock. To protect a tryLock from being unlocked by anyone, a tryLock cannot be released when unlockPassword not matchttlToExpireIncaseUnableToUnlock- expire time of tryLock in case unable to unlock (e.g. exception/error before executing unlock)timeUnit-- Returns:
- the result of get tryLock
-
unlock
unlocks the Distributed Lock instance- Parameters:
lockName- the name of the tryLockunlockPassword- to ensure only the owner is able to unlock, success only when this value equals the unlockPassword specified by tryLock- Returns:
- the result of get release
-
generateUnlockPassword
-
debounced
- Parameters:
key-unlockPassword-ttl-timeUnit-- Returns:
- true is debounced (failed to acquire lock), false is not debounced (acquired lock successfully
-
flashsaleEnable
flash sale - enable- Parameters:
itemId-isEnabled- sale enabled if true, else disabled
-
flashsaleInventoryInit
flash sale - init inventory- Parameters:
itemId-totalAmount- total inventorylimit- max orderAmount per order- Returns:
- true if success
-
flashsaleAcquireQuota
flash sale - order competition before reducing inventory- Parameters:
itemId-requestAmount-- Returns:
- confirmed order amount
-
flashsaleRevokeQuota
flash sale - revoke an order (undo order competition, normally happens when failed to pay within N minutes)- Parameters:
itemId-requestAmount-- Returns:
- the updated inventory booked amount
-
flashsaleInventoryReport
flash sale - inventory report- Parameters:
itemId-- Returns:
-