Command.java 1.42 KB
package com.irrigation.icl.cache;

import lombok.Data;

import java.io.Serializable;

/**
 * Command
 */
@Data
public class Command implements Serializable {

    private static final long serialVersionUID = 7126530485423286910L;

    // 设置本地缓存
    public final static byte OPT_SET = 0x01;
    // 删除本地缓存Key
    public final static byte OPT_DEL = 0x02;
    // 删除本地缓存
    public final static byte OPT_REM = 0x03;

    public byte oper;
    public String name;
    public String key;
    public String src;

    public Command() {
    }

    public Command(String src, byte oper, String name, String key) {
        this.src = src;
        this.oper = oper;
        this.name = name;
        this.key = key;
    }

    /**
     * 更新本地缓存
     *
     * @param cacheName
     * @param key
     * @return
     */
    public static Command set(String src, String cacheName, String key) {
        return new Command(src, OPT_SET, cacheName, key);
    }

    /**
     * 删除本地缓存Key
     *
     * @param cacheName
     * @param key
     * @return
     */
    public static Command del(String src, String cacheName, String key) {
        return new Command(src, OPT_DEL, cacheName, key);
    }

    /**
     * 删除本地缓存
     *
     * @param cacheName
     * @return
     */
    public static Command rem(String src, String cacheName) {
        return new Command(src, OPT_REM, cacheName, null);
    }
}