Interface BootCache

All Known Implementing Classes:
BootCache_RedisImple

public interface BootCache
Author:
Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
  • 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 tryLock
      unlockPassword - unlockPassword is to be used for unlock. To protect a tryLock from being unlocked by anyone, a tryLock cannot be released when unlockPassword not match
      ttlToExpireIncaseUnableToUnlock - expire time of tryLock in case unable to unlock (e.g. exception/error before executing unlock)
      timeUnit -
      Returns:
      the result of get tryLock
    • unlock

      boolean unlock(String lockName, String unlockPassword)
      unlocks the Distributed Lock instance
      Parameters:
      lockName - the name of the tryLock
      unlockPassword - 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

      default String generateUnlockPassword()
    • debounced

      default boolean debounced(String key, String unlockPassword, long ttl, TimeUnit timeUnit)
      Parameters:
      key -
      unlockPassword -
      ttl -
      timeUnit -
      Returns:
      true is debounced (failed to acquire lock), false is not debounced (acquired lock successfully
    • flashsaleEnable

      default void flashsaleEnable(String itemId, boolean isEnabled)
      flash sale - enable
      Parameters:
      itemId -
      isEnabled - sale enabled if true, else disabled
    • flashsaleInventoryInit

      default boolean flashsaleInventoryInit(String itemId, long totalAmount, long limit)
      flash sale - init inventory
      Parameters:
      itemId -
      totalAmount - total inventory
      limit - max orderAmount per order
      Returns:
      true if success
    • flashsaleAcquireQuota

      default long flashsaleAcquireQuota(String itemId, long requestAmount)
      flash sale - order competition before reducing inventory
      Parameters:
      itemId -
      requestAmount -
      Returns:
      confirmed order amount
    • flashsaleRevokeQuota

      default long flashsaleRevokeQuota(String itemId, long requestAmount)
      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

      default FlashSale flashsaleInventoryReport(String itemId)
      flash sale - inventory report
      Parameters:
      itemId -
      Returns: