package cn.zwz.basics.redis;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.DataType;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
/**
* @author 郑为中
* CSDN: Designer 小郑
*/
@ApiOperation(value = "Redis工具类")
@Component
public class RedisTemplateHelper {
@Autowired
private StringRedisTemplate redisTemplate;
@ApiOperation(value = "scan实现")
private void scan(String wayForScan, Consumer<byte[]> consumableList) {
redisTemplate.execute((RedisConnection connection) -> {
try (Cursor<byte[]> cursor = connection.scan(ScanOptions.scanOptions().count(Long.MAX_VALUE).match(wayForScan).build())) {
cursor.forEachRemaining(consumableList);
return null;
} catch (Exception exception) {
throw new RuntimeException(exception);
}
});
}
@ApiOperation(value = "scan获取符合条件的key")
public Set<String> scan(String pattern) {
Set<String> keys = new HashSet<>();
this.scan(pattern, item -> {
String key = new String(item, StandardCharsets.UTF_8);
keys.add(key);
});
return keys;
}
@ApiOperation(value = "通过通配符表达式删除所有")
public void deleteByPattern(String pattern) {
Set<String> keys = this.scan(pattern);
redisTemplate.delete(keys);
}
@ApiOperation(value = "删除key")
public void delete(String key) {
redisTemplate.delete(key);
}
@ApiOperation(value = "批量删除key")
public void delete(Collection<String> keys) {
redisTemplate.delete(keys);
}
@ApiOperation(value = "序列化key")
public byte[] dump(String key) {
return redisTemplate.dump(key);
}
@ApiOperation(value = "是否存在key")
public Boolean hasKey(String key) {
return redisTemplate.hasKey(key);
}
@ApiOperation(value = "设置过期时间")
public Boolean expire(String key, long timeout, TimeUnit unit) {
return redisTemplate.expire(key, timeout, unit);
}
@ApiOperation(value = "设置过期时间")
public Boolean expireAt(String key, Date date) {
return redisTemplate.expireAt(key, date);
}
@ApiOperation(value = "查找匹配的key")
public Set<String> keys(String pattern) {
return redisTemplate.keys(pattern);
}
@ApiOperation(value = "将当前数据库的 key 移动到给定的数据库 db 当中")
public Boolean move(String key, int dbIndex) {
return redisTemplate.move(key, dbIndex);
}
@ApiOperation(value = "移除 key 的过期时间,key 将持久保持")
public Boolean persist(String key) {
return redisTemplate.persist(key);
}
@ApiOperation(value = "返回 key 的剩余的过期时间")
public Long getExpire(String key, TimeUnit unit) {
return redisTemplate.getExpire(key, unit);
}
@ApiOperation(value = "返回 key 的剩余的过期时间")
public Long getExpire(String key) {
return redisTemplate.getExpire(key);
}
@ApiOperation(value = "从当前数据库中随机返回一个 key")
public String randomKey() {
return redisTemplate.randomKey();
}
@ApiOperation(value = "修改 key 的名称")
public void rename(String oldKey, String newKey) {
redisTemplate.rename(oldKey, newKey);
}
@ApiOperation(value = "仅当 newkey 不存在时,将 oldKey 改名为 newkey")
public Boolean renameIfAbsent(String oldKey, String newKey) {
return redisTemplate.renameIfAbsent(oldKey, newKey);
}
@ApiOperation(value = "返回 key 所储存的值的类型")
public DataType type(String key) {
return redisTemplate.type(key);
}
/** -------------------string相关操作--------------------- */
@ApiOperation(value = "设置指定 key 的值")
public void set(String key, String value) {
redisTemplate.opsForValue().set(key, value);
}
@ApiOperation(value = "将值 value 关联到 key ,并将 key 的过期时间设为 timeout")
public void set(String key, String value, long timeout, TimeUnit unit) {
redisTemplate.opsForValue().set(key, value, timeout, unit);
}
@ApiOperation(value = "获取指定 key 的值")
public String get(String key) {
return redisTemplate.opsForValue().get(key);
}
@ApiOperation(value = "返回 key 中字符串值的子字符")
public String getRange(String key, long start, long end) {
return redisTemplate.opsForValue().get(key, start, end);
}
@ApiOperation(value = "将给定 key 的值设为 value ,并返回 key 的旧值(old value)")
public String getAndSet(String key, String value) {
return redisTemplate.opsForValue().getAndSet(key, value);
}
@ApiOperation(value = "对 key 所储存的字符串值,获取指定偏移量上的位(bit)")
public Boolean getBit(String key, long offset) {
return redisTemplate.opsForValue().getBit(key, offset);
}
@ApiOperation(value = "批量获取")
public List<String> multiGet(Collection<String> keys) {
return redisTemplate.opsForValue().multiGet(keys);
}
@ApiOperation(value = "设置ASCII码, 字符串'a'的ASCII码是97, 转为二进制是'01100001', 此方法是将二进制第offset位值变为value",notes = "offset 位置, value: 值,true为1, false为0")
public boolean setBit(String key, long offset, boolean value) {
return redisTemplate.opsForValue().setBit(key, offset, value);
}
@ApiOperation(value = "只有在 key 不存在时设置 key 的值",notes = "之前已经存在返回false, 不存在返回true")
public boolean setIfAbsent(String key, String value) {
return redisTemplate.opsForValue().setIfAbsent(key, value);
}
@ApiOperation(value = "用 value 参数覆写给定 key 所储存的字符串值,从偏移量 offset 开始",notes = "offset:从指定位置开始覆写")
public void setRange(String key, String value, long offset) {
redisTemplate.opsForValue().set(key, value, offset);
}
@ApiOperation(value = "获取字符串的长度")
public Long size(String key) {
return redisTemplate.opsForValue().size(key);
}
@ApiOperation(value = "批量添加")
public void multiSet(Map<String, String> maps) {
redisTemplate.opsForValue().multiSet(maps);
}
@ApiOperation(value = "同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在")
public boolean multiSetIfAbsent(Map<String, String> maps) {
return redisTemplate.opsForValue().multiSetIfAbsent(maps);
}
@ApiOperation(value = "增加(自增长), 负数则为自减")
public Long incrBy(String key, long increment) {
return redisTemplate.opsForValue().increment(key, increment);
}
@ApiOperation(value = "增加(自增长)")
public Double incrByFloat(String key, double increment) {
return redisTemplate.opsForValue().increment(key, increment);
}
@ApiOperation(value = "追加到末尾")
public Integer append
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于JAVA+Vue+SpringBoot+MySQL的教学过程管理系统,包含了课程档案、课程题目、课程成绩、消息通知、课堂签到、课堂任务模块,还包含系统自带的用户管理、部门管理、角色管理、菜单管理、日志管理、数据字典管理、文件管理、图表展示等基础模块,教学过程管理系统基于角色的访问控制,给高校管理员、教师、学生角色使用,可将权限精确到按钮级别,您可以自定义角色并分配权限,系统适合设计精确的权限约束需求。 项目讨论帖:https://bbs.csdn.net/topics/617411738
资源推荐
资源详情
资源评论
收起资源包目录
教学过程管理系统 JAVA毕业设计 Vue+SpringBoot+MySQL (480个子文件)
tree.btl 27KB
table.btl 26KB
tableIndex.btl 17KB
add.btl 9KB
edit.btl 9KB
mpController.btl 4KB
entity.btl 3KB
mplus.btl 1KB
mpServiceImpl.btl 892B
api.btl 861B
treeApi.btl 758B
mapper.btl 367B
mpService.btl 349B
mapperXml.btl 229B
test.coffee 542B
loading2.gif 13KB
vaptcha-loading.gif 1KB
index.html 4KB
RedisTemplateHelper.java 27KB
UserController.java 20KB
PermissionController.java 15KB
ZwzVueGenerator.java 13KB
MyBatisPlusUtils.java 12KB
ZwzWxNoticeUtils.java 11KB
DepartmentController.java 11KB
AchievementController.java 9KB
CreateVerifyCode.java 9KB
FileController.java 8KB
RoleController.java 7KB
WeiChatUtils.java 6KB
SecurityUtil.java 6KB
SystemLogAspect.java 6KB
TitleCollectController.java 6KB
TeacherController.java 6KB
RedisController.java 6KB
TaskItemController.java 5KB
DictDataController.java 5KB
SignItemController.java 5KB
CurriculumTitleController.java 5KB
MyDoorController.java 5KB
PageUtil.java 5KB
CurriculumController.java 5KB
SuperUserController.java 5KB
SignController.java 5KB
StudentController.java 5KB
WebSecurityConfig.java 5KB
AuthenticationFailHandler.java 4KB
NewsController.java 4KB
JwtTokenOncePerRequestFilter.java 4KB
TaskController.java 4KB
RedisExceptionThrowsConfig.java 4KB
AuthenticationSuccessHandler.java 4KB
DictController.java 4KB
IpInfoUtil.java 4KB
QwVerificationCodeController.java 4KB
WeChatUploadMeidaUtils.java 4KB
ZwzFileUtils.java 3KB
User.java 3KB
MyMetaObjectHandler.java 3KB
ZwzBaseController.java 3KB
ResultUtil.java 3KB
SecurityUserDetails.java 3KB
Base64DecodeMultipartFile.java 3KB
ImageValidateFilter.java 3KB
UploadController.java 3KB
SecurityController.java 3KB
Permission.java 3KB
ResponseUtil.java 2KB
ZwzBaseEntity.java 2KB
UserDetailsServiceImpl.java 2KB
ZwzLoginProperties.java 2KB
LogController.java 2KB
Log.java 2KB
MyUserController.java 2KB
ZwzBaseService.java 2KB
SettingController.java 2KB
Department.java 2KB
BeansConfiguration.java 2KB
File.java 2KB
DictData.java 2KB
Achievement.java 2KB
Entity.java 1KB
Field.java 1KB
CommonUtil.java 1KB
MenuVo.java 1KB
Teacher.java 1KB
Sign.java 1KB
Task.java 1KB
Role.java 1KB
TitleCollect.java 1KB
UserRole.java 1KB
CurriculumTitle.java 1KB
StartBean.java 1KB
SignItem.java 1KB
TaskItem.java 1KB
CommonConstant.java 1KB
Dict.java 1KB
ThreadPoolUtil.java 1KB
Result.java 1KB
Curriculum.java 1KB
共 480 条
- 1
- 2
- 3
- 4
- 5
资源评论
- Thermallemon2024-04-26资源是宝藏资源,实用也是真的实用,感谢大佬分享~
- .KEG2024-04-25资源很不错,内容和描述一致,值得借鉴,赶紧学起来!
Designer小郑
- 粉丝: 7w+
- 资源: 155
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- springboot2.4从实战到源码分析Demo源码工程.zip
- 第6次(链表).zip
- 中国移动2023年云化核心网IMS建设工程项目-沈阳电路调单申请.xlsx
- Winform+StackExchange.Redis开发的简单的Redis工具 仅包含读取、删除、写入功能,十分简洁
- 大部分的系统都是基于这个系统,这个系统是大部分系统的过程的网络800系列,作为FG很好的完成了功能
- 提供素材.zip
- JavaWeb程序设计SSM框架选课系统开发大作业有数据库文
- JavaWeb程序设计SSM框架选课系统开发大作业有数据库文
- aubio 是一组算法和工具,用于标记和变换音乐和声音 它扫描或监听音频信号,并尝试识别音乐事件 例如,当鼓被击打时,它能检测到
- 快速的安装系统的过程G800和FG的系统,系统地开发开发一个系统所需要的网络,很好的系统,是优化过的系统
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功