Пример #1
0
func listCommand(cmd *cobra.Command, args []string) {
	cli, err := honoka.New()
	if err != nil {
		Exit(err)
	}

	list, err := cli.List()
	if err != nil {
		Exit(err)
	}
	spew.Dump(list)
}
Пример #2
0
func deleteCommand(cmd *cobra.Command, args []string) {
	if len(args) == 0 {
		Exit(fmt.Errorf("Set cache keys"))
	}
	cli, err := honoka.New()
	if err != nil {
		Exit(err)
	}
	err = cli.Delete(args[0])
	if err != nil {
		Exit(err)
	}
	fmt.Println("success.")
}
Пример #3
0
func setCommand(cmd *cobra.Command, args []string) {
	if len(args) < 3 {
		Exit(fmt.Errorf("Set invalid argments"))
	}
	cli, err := honoka.New()
	if err != nil {
		Exit(err)
	}
	expire, _ := strconv.ParseInt(args[2], 10, 64)
	err = cli.Set(args[0], args[1], expire)
	if err != nil {
		Exit(err)
	}
	fmt.Println("success.")
}
Пример #4
0
func getCommand(cmd *cobra.Command, args []string) {
	if len(args) == 0 {
		Exit(fmt.Errorf("Set cache keys"))
	}
	cli, err := honoka.New()
	if err != nil {
		Exit(err)
	}
	for _, key := range args {
		val, err := cli.GetJson(key)
		if err != nil {
			fmt.Printf("%s: %v\n", key, err)
		} else {
			fmt.Printf("%s: %v\n", key, string(val))
		}
	}
}
Пример #5
0
func outdatedCommand(cmd *cobra.Command, args []string) {
	cli, err := honoka.New()
	if err != nil {
		Exit(err)
	}

	list, err := cli.Outdated()
	if err != nil {
		Exit(err)
	}
	if list == nil {
		fmt.Println("No-indexed cache data is NOTHING.")
	} else {
		for _, bucket := range list {
			fmt.Println(bucket)
		}
	}

}