package com.palmnest.service.redis.impl;

import com.palmnest.dao.redis.BaseRedisDao;
import com.palmnest.service.redis.BaseRedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisStringCommands;
import org.springframework.stereotype.Component;

import java.util.Set;

@Component
public class BaseRedisServiceImpl implements BaseRedisService {

	@Autowired
	private BaseRedisDao baseRedisDao;

	@Override
	public void flushAllCache() {
		baseRedisDao.flushAllCache();
	}

	@Override
	public String get(String key) {
		return baseRedisDao.get(key);
	}

	@Override
	public void set(String key, String value) {
		baseRedisDao.set(key, value);
	}

	@Override
	public void set(String key, String value, long liveTime) {
		baseRedisDao.set(key, value, liveTime);
	}

	@Override
	public Set<String> getKeyValues(String keyLike) {
		return baseRedisDao.getKeyValues("*" + keyLike + "*");
	}

	@Override
	public void dele(String key) {
		baseRedisDao.dele(key);

	}

	@Override
	public Long getDbsize() {
		return baseRedisDao.getDbsize();
	}

	@Override
	public Boolean setBit(String key, Integer index, Boolean tag) {
		return baseRedisDao.setBit(key, index, tag);
	}

	@Override
	public Boolean getBit(String key, Integer index) {
		return baseRedisDao.getBit(key, index);
	}

	@Override
	public Long bitCount(String key) {
		return baseRedisDao.bitCount(key);
	}

	@Override
	public Long bitCount(String key, int start, int end) {
		return baseRedisDao.bitCount(key, start, end);
	}

	@Override
	public Long bitOp(RedisStringCommands.BitOperation op, String saveKey, String... desKey) {
		return baseRedisDao.bitOp(op, saveKey, desKey);
	}

	@Override
	public void delKeyLike(String orgKey) {
		baseRedisDao.delKeyLike("*" + orgKey + "*");
	}

}
