@Override public int size() { return cacheService.hlen(name); }
public void setCacheService(ICacheService cache) { this.cache = cache; if (utils instanceof ICacheService.Aware) { ((ICacheService.Aware) utils).setCacheService(cache); } }
public void clearCache(String scene, IAccount me) throws ServiceException { // 清除缓存 cacheService.del(AreaDivisionQueryer.AREA_DIVISION_KEY, scene); }
@Override public V put(K key, V value) throws CacheException { if (log.isTraceEnabled()) { log.trace("Putting object in cache[{}] for key[{}]", name, key); } try { cacheService.set(name, key.toString(), serializeValue(value)); return null; } catch (Throwable t) { throw new CacheException(t); } }
public Long get(String phone, String type) throws ServiceException { return cache.get(SMS_LAST_SEND_TIME, getKey(phone, type), Long.class); }
@Override public V put(K key, V value) throws CacheException { if (log.isTraceEnabled()) { log.trace("Putting object in cache[{}] for key[{}]", name, key); } try { cacheService.hset(name, key.toString(), serializeValue(value)); return null; } catch (Throwable t) { throw new CacheException(t); } }
/** 设置过期时间 **/ public void expire(K key, Duration time) { cacheService.expire(name, key.toString(), time); if (log.isTraceEnabled()) { String duration = ConvertTools.toDuration(time.toMillis()); log.trace("Set expire time from cache[{}] for key[{}] --> {}", name, key, duration); } }
@Override public V remove(K key) throws CacheException { if (log.isTraceEnabled()) { log.trace("Removing object from cache[{}] for key[{}]", name, key); } try { V previous = get(key); cacheService.hdel(name, key.toString()); return previous; } catch (Throwable t) { throw new CacheException(t); } }
public void sendLoginValidCode(String email) throws ServiceException { String msg = "Failed to SendLoginCode. "; checkEmail(email, msg); // 获得验证码 String validCode = RandomTools.generateNumber(4); // 存入缓存 // 缓存时间(单位:秒) int time = smsService.getCacheTime(Constants.EmailTemplate.login); cache.set(CacheKeys.VALID_CODE_LOGIN.name(), email, validCode, new Second(time)); // 验证码:@1@,@2@分钟内有效。 smsService.send(email, Constants.EmailTemplate.login, validCode, time / 60); }
@Override public void clear() throws CacheException { if (log.isTraceEnabled()) { log.trace("Clearing all objects from cache[" + name + "]"); } try { cacheService.del(name); } catch (Throwable t) { throw new CacheException(t); } }
public void setBaseBusiness(ISmsBaseBusiness utils) { this.utils = utils; if (utils instanceof Config.Aware) { ((Config.Aware) utils).setConfig(config); } if (utils instanceof ICacheService.Aware) { ((ICacheService.Aware) utils).setCacheService(cache); } }
public void sendRegisterValidCode(String email) throws ServiceException { String msg = "Failed to SendRegisterCode. "; checkEmail(email, msg); // 获得验证码 String validCode = RandomTools.generateNumber(4); // 存入缓存 // 缓存时间(单位:秒) int time = smsService.getCacheTime(Constants.EmailTemplate.register); cache.set(CacheKeys.VALID_CODE_REGISTER.name(), email, validCode, new Second(time)); // 验证码:@1@,@2@分钟内有效。 smsService.send(email, Constants.EmailTemplate.register, validCode, time / 60); }
@Override public V remove(K key) throws CacheException { if (log.isTraceEnabled()) { log.trace("Removing object from cache[{}] for key[{}]", name, key); } try { V previous = get(key); cacheService.del(name, key.toString()); return previous; } catch (Throwable t) { throw new CacheException(t); } }
public void sendChangePhoneValidCode(String email) throws ServiceException { String msg = "Failed to SendChangePhoneCode. "; checkEmail(email, msg); // 获得验证码 String validCode = RandomTools.generateNumber(4); // 存入缓存 // 缓存时间(单位:秒) int time = smsService.getCacheTime(Constants.EmailTemplate.change_email); cache.set(CacheKeys.VALID_CODE_CHANGE_PHONE.name(), email, validCode, new Second(time)); // 验证码:@1@,@2@分钟内有效。 smsService.send(email, Constants.EmailTemplate.change_email, validCode, time / 60); }
public void sendRegisterValidCode(String phone) throws ServiceException { String msg = "Failed to SendRegisterCode. "; checkPhone(phone, msg); // 获得验证码 String validCode = RandomTools.generateNumber(4); // 存入缓存 // 缓存时间(单位:秒) int time = smsService.getCacheTime(Constants.SmsTemplate.register); cache.set(CacheKeys.VALID_CODE_REGISTER.name(), phone, validCode, new Second(time)); // 验证码:@1@,@2@分钟内有效。 smsService.send(phone, Constants.SmsTemplate.register, validCode, time / 60); }
public void sendRepasswordValidCode(String email) throws ServiceException { String msg = "Failed to SendRepasswordCode. "; checkEmail(email, msg); // 获得验证码 String validCode = RandomTools.generateNumber(4); // 存入缓存 // 缓存时间(单位:秒) int time = smsService.getCacheTime(Constants.EmailTemplate.repassword); cache.set(CacheKeys.VALID_CODE_REPASSWORD.name(), email, validCode, new Second(time)); // 验证码:@1@,@2@分钟内有效。 smsService.send(email, Constants.EmailTemplate.repassword, validCode, time / 60); }
public void sendRepasswordValidCode(String phone) throws ServiceException { String msg = "Failed to SendRepasswordCode. "; checkPhone(phone, msg); // 获得验证码 String validCode = RandomTools.generateNumber(4); // 存入缓存 // 缓存时间(单位:秒) int time = smsService.getCacheTime(Constants.SmsTemplate.repassword); cache.set(CacheKeys.VALID_CODE_REPASSWORD.name(), phone, validCode, new Second(time)); // 验证码:@1@,@2@分钟内有效。 smsService.send(phone, Constants.SmsTemplate.repassword, validCode, time / 60); }
public void sendLoginValidCode(String phone) throws ServiceException { String msg = "Failed to SendLoginCode. "; checkPhone(phone, msg); // 获得验证码 String validCode = RandomTools.generateNumber(4); // 存入缓存 // 缓存时间(单位:秒) int time = smsService.getCacheTime(Constants.SmsTemplate.login); cache.set(CacheKeys.VALID_CODE_LOGIN.name(), phone, validCode, new Second(time)); // 验证码:@1@,@2@分钟内有效。 smsService.send(phone, Constants.SmsTemplate.login, validCode, time / 60); }
public void sendChangePhoneValidCode(String phone) throws ServiceException { String msg = "Failed to SendChangePhoneCode. "; checkPhone(phone, msg); // 获得验证码 String validCode = RandomTools.generateNumber(4); // 存入缓存 // 缓存时间(单位:秒) int time = smsService.getCacheTime(Constants.SmsTemplate.change_phone); cache.set(CacheKeys.VALID_CODE_CHANGE_PHONE.name(), phone, validCode, new Second(time)); // 验证码:@1@,@2@分钟内有效。 smsService.send(phone, Constants.SmsTemplate.change_phone, validCode, time / 60); }