All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mvnsearch.boot.xtermjs.commands.RedisCommands Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
package org.mvnsearch.boot.xtermjs.commands;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.shell.Availability;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellMethodAvailability;
import org.springframework.shell.standard.ShellOption;

/**
 * Redis commands
 *
 * @author linux_china
 */
@ShellComponent("redis: execute redis commands")
public class RedisCommands {

	@Autowired(required = false)
	private RedisTemplate redisTemplate;

	@ShellMethod(value = "Redis Get")
	public Object redisGet(@ShellOption(help = "Key", defaultValue = "") String key) {
		return redisTemplate.opsForValue().get(key);
	}

	@ShellMethod("Redis Set")
	public String redisSet(@ShellOption(help = "Redis Key", defaultValue = "") String key,
			@ShellOption(help = "Value", defaultValue = "") String value) {
		redisTemplate.opsForValue().set(key, value);
		return "OK";
	}

	@ShellMethodAvailability
	public Availability availabilityOnWeekdays() {
		return redisTemplate != null ? Availability.available()
				: Availability.unavailable("RedisTemplate bean not found!");
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy