mysql实现分布式锁

2020-07-14  本文已影响0人  Rechel_uniq
DROP TABLE IF EXISTS `lock`;
CREATE TABLE `lock`
(
    `id`          bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自定ID',
    `name`        varchar(256)        NOT NULL DEFAULT '' COMMENT '锁名称',
    `capacity`    int(10)             NOT NULL DEFAULT '1' COMMENT '容量',
    `num`         int(10)             NOT NULL DEFAULT '0' COMMENT '当前持有数目',
    `time_length`    int(10)          NOT NULL DEFAULT '0' COMMENT '过期时间',
    `creator`     varchar(256)        NOT NULL DEFAULT '' COMMENT '创建人',
    `deleted`     tinyint(4)          NOT NULL DEFAULT '0' COMMENT '是否删除 0 未删除,1 删除',
    `create_time` bigint(11)          NOT NULL DEFAULT '0' COMMENT '创建时间',
    `update_time` bigint(11)          NOT NULL DEFAULT '0' COMMENT '修改时间',
    PRIMARY KEY (`id`),
    KEY `idx_name` (`name`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_bin COMMENT ='锁表';
@Data
public class Lock {

    @TableId(value= "id", type = IdType.AUTO)
    private Long id;
    private String name;
    private Integer capacity;
    private Integer num;
    private Integer timeLength ;
    private String creator;
    private Long createTime;
    private Long updateTime;

    public Lock() {

    }

    public Lock(String name, Integer capacity, Integer num, Integer timeLength, String creator) {
        this.name = name;
        this.capacity = capacity;
        this.num = num;
        this.timeLength = timeLength;
        this.creator = creator;
    }
}
上一篇 下一篇

猜你喜欢

热点阅读