@Component
public class MemcachedLock {
@Autowired
protected CacheUtils cacheUtils;
private final int minutes = 180;
public boolean lock(String key) {
if (cacheUtils.get(key) == null) {
if (cacheUtils.add(key, minutes, System.currentTimeMillis())) {
return true;
}
}
return false;
}
}