xiejun
2024-11-01 80b6cbfc9c861469146318d0b3dd5f8b8b525b8a
Source/BladeX-Tool/blade-starter-redis/src/main/java/org/springblade/core/redis/lock/RedisLock.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,82 @@
/*
 *      Copyright (c) 2018-2028, DreamLu All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: DreamLu å¢æ˜¥æ¢¦ (596392912@qq.com)
 */
package org.springblade.core.redis.lock;
import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;
/**
 * åˆ†å¸ƒå¼é”æ³¨è§£ï¼Œredisson,支持的锁的种类有很多,适合注解形式的只有重入锁、公平锁
 *
 * <p>
 * 1. å¯é‡å…¥é”ï¼ˆReentrant Lock)
 * 2. å…¬å¹³é”ï¼ˆFair Lock)
 * 3. è”锁(MultiLock)
 * 4. çº¢é”ï¼ˆRedLock)
 * 5. è¯»å†™é”ï¼ˆReadWriteLock)
 * </p>
 *
 * @author L.cm
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface RedisLock {
   /**
    * åˆ†å¸ƒå¼é”çš„ key,必须:请保持唯一性
    *
    * @return key
    */
   String value();
   /**
    * åˆ†å¸ƒå¼é”å‚数,可选,支持 spring el # è¯»å–方法参数和 @ è¯»å– spring bean
    *
    * @return param
    */
   String param() default "";
   /**
    * ç­‰å¾…锁超时时间,默认30
    *
    * @return int
    */
   long waitTime() default 30;
   /**
    * è‡ªåŠ¨è§£é”æ—¶é—´ï¼Œè‡ªåŠ¨è§£é”æ—¶é—´ä¸€å®šå¾—å¤§äºŽæ–¹æ³•æ‰§è¡Œæ—¶é—´ï¼Œå¦åˆ™ä¼šå¯¼è‡´é”æå‰é‡Šæ”¾ï¼Œé»˜è®¤100
    *
    * @return int
    */
   long leaseTime() default 100;
   /**
    * æ—¶é—´å•温,默认为秒
    *
    * @return æ—¶é—´å•位
    */
   TimeUnit timeUnit() default TimeUnit.SECONDS;
   /**
    * é»˜è®¤å…¬å¹³é”
    *
    * @return LockType
    */
   LockType type() default LockType.FAIR;
}