func LimitDispatcher(command string, limit int, rdb *redis.Client) (*Dispatcher, error) {
	dispatcher := new(Dispatcher)
	_, err := rdb.Ping(context.Background()).Result()
	if err != nil {
		return nil, err
	}
	dispatcher.redisClient = rdb
	values := strings.Split(command, "-")
	if len(values) != 2 {
		log.Println("Some error with your input command!, the len of your command is ", len(values))
		return nil, FormatError
	}
	unit, err := strconv.Atoi(values[0])
	if err != nil {
		return nil, FormatError
	}
	if unit <= 0 {
		return nil, CommandError
	}
	if t, ok := timeDict[strings.ToUpper(values[1])]; ok {
		dispatcher.period = time.Duration(unit) * t
	} else {
		return nil, FormatError
	}
	if limit <= 0 {
		return nil, LimitError
	}
	dispatcher.limit = limit
	resetSHA, err := dispatcher.redisClient.ScriptLoad(context.Background(), ResetScript).Result()
	if err != nil {
		return nil, err
	}
	normalSHA, err := dispatcher.redisClient.ScriptLoad(context.Background(), Script).Result()
	if err != nil {
		return nil, err
	}
	shaScript := make(map[string]string)
	shaScript["reset"] = resetSHA
	shaScript["normal"] = normalSHA
	dispatcher.shaScript = shaScript
	return dispatcher, nil
}
create a limit dispatcher object with command and limit request number.
package limiter
import (
	"context"
	"errors"
	"log"
	"net/http"
	"strconv"
	"strings"
	"time"
	"github.com/gin-gonic/gin"
	"github.com/go-redis/redis/v8"
)
const TimeFormat = "2006-01-02 15:04:05"
var (
	LimitError   = errors.New("Limit should > 0.")
	CommandError = errors.New("The command of first number should > 0.")
	FormatError  = errors.New("Please check the format with your input.")
	MethodError  = errors.New("Please check the method is one of http method.")
	ServerError  = errors.New("StatusInternalServerError, please wait a minute.")
)
var timeDict = map[string]time.Duration{
	"S": time.Second,
	"M": time.Minute,
	"H": time.Hour,
	"D": time.Hour * 24,
}
type Dispatcher struct {
	limit       int
	deadline    int64
	shaScript   map[string]string
	period      time.Duration
	redisClient *redis.Client
}