RedisService.java 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. package com.cyksj.redis;
  2. import com.cyksj.common.util.StringUtil;
  3. import lombok.AllArgsConstructor;
  4. import lombok.Getter;
  5. import org.springframework.data.redis.core.RedisTemplate;
  6. import org.springframework.data.redis.core.ZSetOperations;
  7. import org.springframework.stereotype.Service;
  8. import javax.annotation.Resource;
  9. import java.util.Arrays;
  10. import java.util.List;
  11. import java.util.Map;
  12. import java.util.Set;
  13. import java.util.concurrent.TimeUnit;
  14. /**
  15. * @description 定义常用的 Redis操作
  16. * @author chan
  17. * @date 2021-03-31 5:34 下午
  18. */
  19. @Service
  20. @SuppressWarnings("all")
  21. public class RedisService {
  22. @Resource
  23. private RedisTemplate<String, Object> redisTemplate;
  24. public static String env = "dev";
  25. /**
  26. * 指定缓存失效时间
  27. *
  28. * @param key 键
  29. * @param time 时间(秒)
  30. * @return Boolean
  31. */
  32. public Boolean expire(String key, Long time) {
  33. try {
  34. if (time > 0) {
  35. redisTemplate.expire(key, time, TimeUnit.SECONDS);
  36. }
  37. return true;
  38. } catch (Exception e) {
  39. e.printStackTrace();
  40. return false;
  41. }
  42. }
  43. /**
  44. * 根据key获取过期时间
  45. *
  46. * @param key 键 不能为 null
  47. * @return 时间(秒) 返回 0代表为永久有效
  48. */
  49. public Long getExpire(String key) {
  50. return redisTemplate.getExpire(key, TimeUnit.SECONDS);
  51. }
  52. /**
  53. * 判断 key是否存在
  54. *
  55. * @param key 键
  56. * @return true 存在 false不存在
  57. */
  58. public Boolean hasKey(String key) {
  59. try {
  60. return redisTemplate.hasKey(key);
  61. } catch (Exception e) {
  62. e.printStackTrace();
  63. return false;
  64. }
  65. }
  66. /**
  67. * 删除缓存
  68. *
  69. * @param key 可以传一个值 或多个
  70. */
  71. public void del(String... key) {
  72. if (key != null && key.length > 0) {
  73. if (key.length == 1) {
  74. redisTemplate.delete(key[0]);
  75. } else {
  76. redisTemplate.delete(Arrays.asList(key));
  77. }
  78. }
  79. }
  80. /**
  81. * 普通缓存获取
  82. *
  83. * @param key 键
  84. * @return 值
  85. */
  86. public Object get(String key) {
  87. return key == null ? null : redisTemplate.opsForValue().get(key);
  88. }
  89. /**
  90. * String缓存获取
  91. * @param key 键
  92. * @return 值
  93. */
  94. public String getStr(String key) {
  95. return key == null ? null : StringUtil.getString(redisTemplate.opsForValue().get(key));
  96. }
  97. /**
  98. * 普通缓存放入
  99. *
  100. * @param key 键
  101. * @param value 值
  102. * @return true成功 false失败
  103. */
  104. public Boolean set(String key, Object value) {
  105. try {
  106. redisTemplate.opsForValue().set(key, value);
  107. return true;
  108. } catch (Exception e) {
  109. e.printStackTrace();
  110. return false;
  111. }
  112. }
  113. /**
  114. * 普通缓存放入并设置时间
  115. *
  116. * @param key 键
  117. * @param value 值
  118. * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
  119. * @return true成功 false 失败
  120. */
  121. public Boolean set(String key, Object value, Long time) {
  122. try {
  123. if (time > 0) {
  124. redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
  125. } else {
  126. set(key, value);
  127. }
  128. return true;
  129. } catch (Exception e) {
  130. e.printStackTrace();
  131. return false;
  132. }
  133. }
  134. /**
  135. * 递增
  136. *
  137. * @param key 键
  138. * @param delta 要增加几(大于0)
  139. * @return Long
  140. */
  141. public Long incr(String key, Long delta) {
  142. if (delta < 0) {
  143. throw new RuntimeException("递增因子必须大于0");
  144. }
  145. return redisTemplate.opsForValue().increment(key, delta);
  146. }
  147. /**
  148. * 递减
  149. *
  150. * @param key 键
  151. * @param delta 要减少几
  152. * @return Long
  153. */
  154. public Long decr(String key, Long delta) {
  155. if (delta < 0) {
  156. throw new RuntimeException("递减因子必须大于0");
  157. }
  158. return redisTemplate.opsForValue().increment(key, -delta);
  159. }
  160. /**
  161. * HashGet
  162. *
  163. * @param key 键 不能为 null
  164. * @param item 项 不能为 null
  165. * @return 值
  166. */
  167. public Object hget(String key, String item) {
  168. return redisTemplate.opsForHash().get(key, item);
  169. }
  170. /**
  171. * 获取 hashKey对应的所有键值
  172. *
  173. * @param key 键
  174. * @return 对应的多个键值
  175. */
  176. public Map<Object, Object> hmget(String key) {
  177. return redisTemplate.opsForHash().entries(key);
  178. }
  179. /**
  180. * HashSet
  181. *
  182. * @param key 键
  183. * @param map 对应多个键值
  184. * @return true 成功 false 失败
  185. */
  186. public Boolean hmset(String key, Map<String, Object> map) {
  187. try {
  188. redisTemplate.opsForHash().putAll(key, map);
  189. return true;
  190. } catch (Exception e) {
  191. e.printStackTrace();
  192. return false;
  193. }
  194. }
  195. /**
  196. * HashSet 并设置时间
  197. *
  198. * @param key 键
  199. * @param map 对应多个键值
  200. * @param time 时间(秒)
  201. * @return true成功 false失败
  202. */
  203. public Boolean hmset(String key, Map<String, Object> map, Long time) {
  204. try {
  205. redisTemplate.opsForHash().putAll(key, map);
  206. if (time > 0) {
  207. expire(key, time);
  208. }
  209. return true;
  210. } catch (Exception e) {
  211. e.printStackTrace();
  212. return false;
  213. }
  214. }
  215. /**
  216. * 向一张hash表中放入数据,如果不存在将创建
  217. *
  218. * @param key 键
  219. * @param item 项
  220. * @param value 值
  221. * @return true 成功 false失败
  222. */
  223. public Boolean hset(String key, String item, Object value) {
  224. try {
  225. redisTemplate.opsForHash().put(key, item, value);
  226. return true;
  227. } catch (Exception e) {
  228. e.printStackTrace();
  229. return false;
  230. }
  231. }
  232. /**
  233. * 向一张hash表中放入数据,如果不存在将创建
  234. *
  235. * @param key 键
  236. * @param item 项
  237. * @param value 值
  238. * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
  239. * @return true 成功 false失败
  240. */
  241. public Boolean hset(String key, String item, Object value, Long time) {
  242. try {
  243. redisTemplate.opsForHash().put(key, item, value);
  244. if (time > 0) {
  245. expire(key, time);
  246. }
  247. return true;
  248. } catch (Exception e) {
  249. e.printStackTrace();
  250. return false;
  251. }
  252. }
  253. /**
  254. * 删除hash表中的值
  255. *
  256. * @param key 键 不能为 null
  257. * @param item 项 可以使多个不能为 null
  258. */
  259. public void hdel(String key, Object... item) {
  260. redisTemplate.opsForHash().delete(key, item);
  261. }
  262. /**
  263. * 判断hash表中是否有该项的值
  264. *
  265. * @param key 键 不能为 null
  266. * @param item 项 不能为 null
  267. * @return true 存在 false不存在
  268. */
  269. public Boolean hHasKey(String key, String item) {
  270. return redisTemplate.opsForHash().hasKey(key, item);
  271. }
  272. /**
  273. * hash递增 如果不存在,就会创建一个 并把新增后的值返回
  274. *
  275. * @param key 键
  276. * @param item 项
  277. * @param by 要增加几(大于0)
  278. * @return Double
  279. */
  280. public Double hincr(String key, String item, Double by) {
  281. return redisTemplate.opsForHash().increment(key, item, by);
  282. }
  283. /**
  284. * hash递减
  285. *
  286. * @param key 键
  287. * @param item 项
  288. * @param by 要减少记(小于0)
  289. * @return Double
  290. */
  291. public Double hdecr(String key, String item, Double by) {
  292. return redisTemplate.opsForHash().increment(key, item, -by);
  293. }
  294. /**
  295. * 根据 key获取 Set中的所有值
  296. *
  297. * @param key 键
  298. * @return Set
  299. */
  300. public Set<Object> sGet(String key) {
  301. try {
  302. return redisTemplate.opsForSet().members(key);
  303. } catch (Exception e) {
  304. e.printStackTrace();
  305. return null;
  306. }
  307. }
  308. /**
  309. * 根据value从一个set中查询,是否存在
  310. *
  311. * @param key 键
  312. * @param value 值
  313. * @return true 存在 false不存在
  314. */
  315. public Boolean sHasKey(String key, Object value) {
  316. try {
  317. return redisTemplate.opsForSet().isMember(key, value);
  318. } catch (Exception e) {
  319. e.printStackTrace();
  320. return false;
  321. }
  322. }
  323. /**
  324. * 将数据放入set缓存
  325. *
  326. * @param key 键
  327. * @param values 值 可以是多个
  328. * @return 成功个数
  329. */
  330. public Long sSet(String key, Object... values) {
  331. try {
  332. return redisTemplate.opsForSet().add(key, values);
  333. } catch (Exception e) {
  334. e.printStackTrace();
  335. return 0L;
  336. }
  337. }
  338. /**
  339. * 将set数据放入缓存
  340. *
  341. * @param key 键
  342. * @param time 时间(秒)
  343. * @param values 值 可以是多个
  344. * @return 成功个数
  345. */
  346. public Long sSetAndTime(String key, Long time, Object... values) {
  347. try {
  348. Long count = redisTemplate.opsForSet().add(key, values);
  349. if (time > 0) {
  350. expire(key, time);
  351. }
  352. return count;
  353. } catch (Exception e) {
  354. e.printStackTrace();
  355. return 0L;
  356. }
  357. }
  358. /**
  359. * 获取set缓存的长度
  360. *
  361. * @param key 键
  362. * @return Long
  363. */
  364. public Long sGetSetSize(String key) {
  365. try {
  366. return redisTemplate.opsForSet().size(key);
  367. } catch (Exception e) {
  368. e.printStackTrace();
  369. return 0L;
  370. }
  371. }
  372. /**
  373. * 移除值为value的
  374. *
  375. * @param key 键
  376. * @param values 值 可以是多个
  377. * @return 移除的个数
  378. */
  379. public Long setRemove(String key, Object... values) {
  380. try {
  381. return redisTemplate.opsForSet().remove(key, values);
  382. } catch (Exception e) {
  383. e.printStackTrace();
  384. return 0L;
  385. }
  386. }
  387. /**
  388. * 获取list缓存的内容
  389. *
  390. * @param key 键
  391. * @param start 开始
  392. * @param end 结束 0 到 -1代表所有值
  393. * @return List
  394. */
  395. public List<Object> lGet(String key, Long start, Long end) {
  396. try {
  397. return redisTemplate.opsForList().range(key, start, end);
  398. } catch (Exception e) {
  399. e.printStackTrace();
  400. return null;
  401. }
  402. }
  403. /**
  404. * 获取list缓存的长度
  405. *
  406. * @param key 键
  407. * @return Long
  408. */
  409. public Long lGetListSize(String key) {
  410. try {
  411. return redisTemplate.opsForList().size(key);
  412. } catch (Exception e) {
  413. e.printStackTrace();
  414. return 0L;
  415. }
  416. }
  417. /**
  418. * 通过索引 获取list中的值
  419. *
  420. * @param key 键
  421. * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;
  422. * index<0时,-1,表尾,-2倒数第二个元素,依次类推
  423. * @return Object
  424. */
  425. public Object lGetIndex(String key, Long index) {
  426. try {
  427. return redisTemplate.opsForList().index(key, index);
  428. } catch (Exception e) {
  429. e.printStackTrace();
  430. return null;
  431. }
  432. }
  433. /**
  434. * 将list放入缓存
  435. *
  436. * @param key 键
  437. * @param value 值
  438. * @return Boolean
  439. */
  440. public Boolean lSet(String key, Object value) {
  441. try {
  442. redisTemplate.opsForList().rightPush(key, value);
  443. return true;
  444. } catch (Exception e) {
  445. e.printStackTrace();
  446. return false;
  447. }
  448. }
  449. /**
  450. * 将list放入缓存
  451. *
  452. * @param key 键
  453. * @param value 值
  454. * @param time 时间(秒)
  455. * @return Boolean
  456. */
  457. public Boolean lSet(String key, Object value, Long time) {
  458. try {
  459. redisTemplate.opsForList().rightPush(key, value);
  460. if (time > 0) {
  461. expire(key, time);
  462. }
  463. return true;
  464. } catch (Exception e) {
  465. e.printStackTrace();
  466. return false;
  467. }
  468. }
  469. /**
  470. * 将list放入缓存
  471. *
  472. * @param key 键
  473. * @param value 值
  474. * @return Boolean
  475. */
  476. public Boolean lSet(String key, List<Object> value) {
  477. try {
  478. redisTemplate.opsForList().rightPushAll(key, value);
  479. return true;
  480. } catch (Exception e) {
  481. e.printStackTrace();
  482. return false;
  483. }
  484. }
  485. /**
  486. * 将list放入缓存
  487. *
  488. * @param key 键
  489. * @param value 值
  490. * @param time 时间(秒)
  491. * @return Boolean
  492. */
  493. public Boolean lSet(String key, List<Object> value, Long time) {
  494. try {
  495. redisTemplate.opsForList().rightPushAll(key, value);
  496. if (time > 0) {
  497. expire(key, time);
  498. }
  499. return true;
  500. } catch (Exception e) {
  501. e.printStackTrace();
  502. return false;
  503. }
  504. }
  505. /**
  506. * 根据索引修改list中的某条数据
  507. *
  508. * @param key 键
  509. * @param index 索引
  510. * @param value 值
  511. * @return Boolean
  512. */
  513. public Boolean lUpdateIndex(String key, Long index, Object value) {
  514. try {
  515. redisTemplate.opsForList().set(key, index, value);
  516. return true;
  517. } catch (Exception e) {
  518. e.printStackTrace();
  519. return false;
  520. }
  521. }
  522. /**
  523. * 移除N个值为value
  524. *
  525. * @param key 键
  526. * @param count 移除多少个
  527. * @param value 值
  528. * @return 移除的个数
  529. */
  530. public Long lRemove(String key, Long count, Object value) {
  531. try {
  532. return redisTemplate.opsForList().remove(key, count, value);
  533. } catch (Exception e) {
  534. e.printStackTrace();
  535. return 0L;
  536. }
  537. }
  538. public boolean setNx(String key, Object value, Long time) {
  539. if (time > 0) {
  540. return redisTemplate.opsForValue().setIfAbsent(key, value, time, TimeUnit.SECONDS);
  541. }
  542. return false;
  543. }
  544. /**
  545. * 添加元素到ZSet
  546. */
  547. public Boolean zAdd(String key, double score, Object value) {
  548. try {
  549. return redisTemplate.opsForZSet().add(key, value, score);
  550. } catch (Exception e) {
  551. e.printStackTrace();
  552. return false;
  553. }
  554. }
  555. // 增加ZSet元素的分数
  556. public Double zIncrementScore(String key, String value, double delta) {
  557. try {
  558. return redisTemplate.opsForZSet().incrementScore(key, value, delta);
  559. } catch (Exception e) {
  560. e.printStackTrace();
  561. return null;
  562. }
  563. }
  564. // 封装获取ZSet分数操作
  565. public Double zScore(String key, Object value) {
  566. try {
  567. return redisTemplate.opsForZSet().score(key, value);
  568. } catch (Exception e) {
  569. e.printStackTrace();
  570. return null;
  571. }
  572. }
  573. // 封装ZSet添加或更新分数操作
  574. public Boolean zAddOrUpdateScore(String key, Object value, double score) {
  575. try {
  576. return redisTemplate.opsForZSet().add(key, value, score);
  577. } catch (Exception e) {
  578. e.printStackTrace();
  579. return false;
  580. }
  581. }
  582. /**
  583. * 获取ZSet的大小
  584. */
  585. public Long zCard(String key) {
  586. try {
  587. return redisTemplate.opsForZSet().zCard(key);
  588. } catch (Exception e) {
  589. e.printStackTrace();
  590. return null;
  591. }
  592. }
  593. /**
  594. * 获取ZSet的大小
  595. */
  596. public Long zCount(String key, long start, long end) {
  597. try {
  598. return redisTemplate.opsForZSet().count(key, start, end);
  599. } catch (Exception e) {
  600. e.printStackTrace();
  601. return null;
  602. }
  603. }
  604. // 封装获取ZSet范围内成员的方法
  605. public Set<Object> zRange(String key, long start, long end) {
  606. try {
  607. ZSetOperations<String, Object> zSetOperations = redisTemplate.opsForZSet();
  608. return zSetOperations.range(key, start, end);
  609. } catch (Exception e) {
  610. e.printStackTrace();
  611. return null;
  612. }
  613. }
  614. /**
  615. * 删除ZSet中分数范围内的元素
  616. */
  617. public Long zRemoveRangeByScore(String key, double min, double max) {
  618. try {
  619. return redisTemplate.opsForZSet().removeRangeByScore(key, min, max);
  620. } catch (Exception e) {
  621. e.printStackTrace();
  622. return 0L;
  623. }
  624. }
  625. /**
  626. * 返回有序集 key 中,所有分数介于 min 和 max 之间(包括等于 min 或 max)的成员。
  627. * 有序集成员按分数值递增(从小到大)次序排列。
  628. * 此方法还支持限制返回的元素数量。
  629. *
  630. * @param key 有序集合的key
  631. * @param min 分数范围的最小值
  632. * @param max 分数范围的最大值
  633. * @param offset 开始返回的索引位置
  634. * @param count 返回的最大元素数量
  635. * @return 介于最小值和最大值之间的成员的集合
  636. */
  637. public Set<Object> zRangeByScore(String key, double min, double max, long offset, long count) {
  638. return redisTemplate.opsForZSet().rangeByScore(key, min, max, offset, count);
  639. }
  640. /**
  641. * 从ZSet获取所有成员及其分数
  642. * @param key ZSet的键
  643. * @return ZSet中所有成员及其分数的集合
  644. */
  645. public Set<ZSetOperations.TypedTuple<Object>> zRangeWithScores(String key, long start, long end){
  646. return redisTemplate.opsForZSet().rangeWithScores(key, start, end);
  647. }
  648. /**
  649. * 检查指定值是否存在于有序集合中
  650. * @param key
  651. * @param value
  652. * @return
  653. */
  654. public boolean checkValueExistsInZSet(String key, String value) {
  655. // 检查指定值是否存在于有序集合中
  656. return redisTemplate.opsForZSet().score(key, value) != null;
  657. }
  658. /**
  659. * 从ZSet中删除指定的成员
  660. *
  661. * @param key ZSet的键
  662. * @param value 要删除的成员值
  663. * @return 被成功移除的成员数量
  664. */
  665. public Long zRemove(String key, Object value) {
  666. try {
  667. return redisTemplate.opsForZSet().remove(key, value);
  668. } catch (Exception e) {
  669. e.printStackTrace();
  670. return 0L;
  671. }
  672. }
  673. public Set<String> keys(String name) {
  674. return redisTemplate.keys(name);
  675. }
  676. @AllArgsConstructor
  677. @Getter
  678. public enum key {
  679. CORP_AUTH_MAPPING_KEY("mapping:corp:", "企业微信授权跳转", 60 * 60 * 24L),
  680. CORP_ACCESSO_TOKEN_KEY("corp:access_token:", "corp_access_token", 60 * 30L),
  681. MAPPING_INDEX_KEY("mapper:index:", "授权跳转", 60 * 10L),
  682. WX_LOGIN_AUTH_URI("wx_login_auth_uri:%s:%s", "微信网页授权登录uri", 60 * 60 * 24L),
  683. RECOMMEND_COUPON_DAY("recommend_coupon_day:%s", "推荐优惠券弹窗", 60 * 60 * 24L),
  684. EMAIL_CODE_KEY("email_code_key:%s", "邮箱验证码", 60 * 3),
  685. PHONE_CODE_KEY("phone_code_key:", "短信验证码", 60 * 3),
  686. PHONE_CODE_USER_NUM_KEY_DAY("phone_code_user_num_key:", "近一天获取验证码次数", 60 * 60 * 24l),
  687. PHONE_CODE_BALCK_KEY("phone_code_balck_key:", "手机黑名单", -1l),
  688. PHONE_CODE_RETRY_TIME_KEY("phone_code_retry_time_key:", "手机登录重试key", 60 * 3),
  689. BALCK_USER_IP_KEY("balck_user_ip_key:", "拉黑用户ip", 60 * 60 * 24),
  690. LOTTERY_KEY("lottery_key:%s", "抽奖key", 60 * 60 * 24l),
  691. TASK_TIME_LIMIT_KEY("task_time_limit:%s", "一次性任务key", 30),
  692. WX_GZH_QRCODE_LOGIN("wx_gzh_qrcode_login:%s", "微信公众号扫码登录key", 60),
  693. WX_GZH_QRCODE_BIND("wx_gzh_qrcode_bind:%s", "pc手机用户购买车票绑定wx", 60),
  694. WX_GZH_QRCODE_SHARED_LOGIN("wx_gzh_qrcode_shared_login:%s", "微信公众号扫码分享邀请key", 60),
  695. EQUIPMENT_DISTRIBUTE_COUPON_KEY("equipment_distribute_coupon_key:%s", "实物设备分销新用户优惠券展示key", 60),
  696. CMS_USER_KEY("cms:user:%s:", "user缓存前缀", 60 * 60 * 24L * 7),
  697. CMS_USER_ROLE_KEY("cms:user:role:%s:", "user角色缓存前缀", 60 * 60 * 24L * 7),
  698. CMS_USER_PERMISSION_KEY("cms:user:permission:%s:", "user权限缓存前缀", 60 * 60 * 24L * 7),
  699. REPEAT_USER_KEY("repeat_user_key:%s:", "重复用户插入key", 60l),
  700. BUSINESS_FIRST_ORDER_USER_KEY("business_first_order_user_key:%s:", "商务分销首单提成key", 60l),
  701. PC_WEB_CACHE("pc_web_cache", "首页平台缓存", 10 * 60),
  702. H5_WEB_CACHE("h5_web_cache", "h5首页平台缓存", 10 * 60),
  703. YH_HOME_PAGHE_CACHE("yh_home_paghe_cache:", "银河首页缓存", 30 * 60),
  704. YH_HOME_PAGHE_CACHE_SHOP("yh_home_paghe_cache:shop:", "银河首页店铺缓存", 40 * 60),
  705. YH_GOODS_QUESTIONS_DETAIL("yh_goods_questions_detail:%s:%s", "平台售后问题", 60 * 60 * 24),
  706. REGISTER_HOME_PAGE_CACHE("register_home_page_cache:", "注册首页缓存", 10 * 60),
  707. CPS_BACK_LOGIN_KEY("cps_back_login:", "cps商务后台登录key", 3 * 60),
  708. CPS_AUTH_SUCCESS_KEY("cps_auth_success_key:%s", "cps后台微信授权", 60 * 10),
  709. YH_SHOP_BACK_LOGIN_KEY("yh_shop_back_login:", "店铺主后台key", 3 * 60),
  710. YH_SHOP_AUTH_SUCCESS_KEY("yh_shop_auth_success_key:%s", "店铺主后台微信授权", 60 * 10),
  711. QUESTION_RESPONSE_KEY("question_response_key:%s", "问卷回答key", 60 * 60 * 24L),
  712. IMPORT_ACCOUNT_CACHE_KEY("import_account_cache_key:%s", "导入缓存key", 60 * 10L),
  713. MAKERTING_MSG_KEY("makerting_msg_key", "营销短信", 60 * 60 * 24 * 30),
  714. PHONE_AREA_CODE("phone_area_code:key", "国家或地区码", 60 * 60 * 24 * 15),
  715. CORP_CHAT_GROUP_CODE("corp_chat_group_code:", "企业微信群动态码", 60 * 60 * 24 * 15),
  716. CORP_SERVICE_QR_CODE("corp_service_qr_code:", "企业微信客服活码", 60 * 60 * 24 * 15),
  717. GENERAL_POPULARIZE_CODE("general_popularize_code:", "普通推广者关联优惠券", 10l),
  718. //企业微信欢迎语 临时素材 mediaId
  719. CORP_WECLOME_MEDIA("corp:%s:weclome:media:","临时素材 mediaId",60*60*24*3 - 60*60*1L),
  720. CORP_UPLOAD_ATTACHMENTS("corp:%s:upload:attachments:","临时附件",60*60*24*3 - 60*60*1L),
  721. CORP_DYNAMIC_RULE_TAG_KEY("corp_dynamic_rule_tag_key:", "企业微信动态标签key", 60 * 60L),
  722. ORDER_DON_POST_DATA_USER_KEY("order_don_post_data_user_key:", "用户订单回传缓存key", -1L),
  723. ABROAD_SUCCESS_URL("abroad:pay:success_url:","海外支付成功页",60 * 60 * 24L),
  724. CHAT_GPT_TOKEN_KEY("chat_gpt_token_key:", "chatGPT直连token key", 60 * 10l),
  725. CHAT_GPT_TOKEN_EXCEPTION_KEY("chat_gpt_token_exception_key:", "chatGPT直连token异常 key", -1l),
  726. ORDER_COMMENT_KEY("order_comment_key:", "订单评价", 10l),
  727. USER_BIND_ACCOUNT_INFO_KEY("user_bind_account_info_key:", "用户绑定其他账号key", 10l),
  728. TASK_RECEIVED_KEY("task_received_key:%s:%s", "领取任务奖励key", 10l),
  729. CORP_GROUP_CHAT_LIST("corp_group_chat_list:%s", "企业微信客户群列表", 60 * 60 * 24),
  730. PLUS_GOODS_ADDRESS_KEY("plus_goods_address_key:", "优惠加购实物地址key", 10 * 60l),
  731. GROUPS_TRIPS_OUTSIDE_RELATION("groups_trips_outside_relation:key:%s:%s", "额外车位", 30l),
  732. DISTRIBUTE_RULE_TIME_KEY("DISTRIBUTE_RULE_TIME_KEY", "渠道规格记录时间key", 5 * 60L),
  733. //巨量广告平台临时存储 callback
  734. OCEANENGINE_MONITOR_CALLBCAK("oceanengine:monitor:callback","巨量广告投放临时数据",60L*60L*24L),
  735. CORP_FOLLOW_ACTIVE_CODE_KEY("corp_follow_active_code_key:%s:%s", "活动客服活码key", 60 * 61),
  736. CORP_FOLLOW_ACTIVE_CODE_CLEAN_KEY("corp_follow_active_code_key:%s", "活动客服活码清除key", -1),
  737. REAL_GOODS_BENEFITS_KEY("real_goods_benefits_key:%s", "实物权益key", 60 * 5l),
  738. USER_DISTRIBUTE_ADD_KEY("user_distribute_add_key:%s", "分销用户新增key", 30l),
  739. CORP_CUSTOMER_ACQUISTION_CLICKID("corp:customer:post:%s","巨量投放,获客链接 跳转存储点击id",60*60*24),
  740. CORP_CUSTOMER_ACQUISTION_START_CHAT("corp:customer:post:start_chat","获客链接 发起回话存储点击id",60*60*24),
  741. CORP_CUSTOMER_ACQUISTION_START_CHAT_COUNT("corp:customer:post:start_chat:count:%s","获客链接 发起回话回传计数",60*60*24),
  742. CORP_CUSTOMER_ACQUISTION_START_CHAT_SET("corp:customer:post:start_chat_set","获客链接 发起回话待回传set",60*60*24),
  743. //获客链接 到企业微信内将平台标识与unionId 对应
  744. CORP_CUSTOMER_ACQUISTION_UNIONID_CLICKID("corp:customer:unionId:%s","unionid 对应的clickId",60*60*24),
  745. WEEKEND_DUTY_UNDERSTAFFED_NOTIFY("weekend_duty_understaffed_notify","周末值班人员不足短信通知key",60*60),
  746. DOUBLE_VERIFY_CODE_VIEW_MINUTES_KEY("double_verify_code_view_minutes_key","双重验证码查看同时间段人数限制",60),
  747. WX_INDENT_BIND_KEY("wx_indent_bind:key:", "微信身份授权绑定key", 60 * 60 * 24),
  748. EQUIPMENT_USER_SERVICE_RECORD("equipment_user_service_record:", "用户设备客服获取记录key", 60 * 60 * 24),
  749. INFORMATION_KEY("information_key:", "文章", 30 * 60L),
  750. CLOSE_ORDER_TIME_KEY("close_order_time_key:", "关闭订单key", 3 * 60),
  751. CLOSE_UPGRADE_ORDER_TIME_KEY("close_upgrade_order_time_key:", "关闭订单key", 3 * 60),
  752. CHATGPT_CONVERSATION_LIMIT("chatgpt:conversation:limit:", "chatGpt 对话限制", 3 * 60 * 60L),
  753. CHATGPT_CAR_SCORES("chatgpt:car:scores","chatGpt 车队分数", 48 * 60 * 60L),
  754. CHATGPT_CAR_HIGH_CHAT("chatgpt:car:high:chat:","chatGpt gpt4 对话次数", 48 * 60 * 60L),
  755. CHATGPT_CAR_LOW_CHAT("chatgpt:car:low:chat:","chatGpt 3.5 对话次数", 48 * 60 * 60L),
  756. //claude
  757. CLAUDE_CONVERSATION_LIMIT("claude:conversation:limit:", "claude 对话限制", 3 * 60 * 60L),
  758. CLAUDE_CAR_CHAT("claude:car:chat:","claude 对话次数", 48 * 60 * 60L),
  759. CLAUDE_CAR_SCORES("claude:car:scores","claude 车队分数", 48 * 60 * 60L),
  760. //车票到期前每日通知key
  761. TICKET_EXPIRY_NOTIFY_DAY("ticket_expiry_notify_day:%s:%s", "车票到期前每日通知key", 60 * 60 * 24L),
  762. MIDJOURNEY_FAST_LIMIT("midjourney:fast:limit:", "midjourney fast次数", 60 * 60 * 48L),
  763. MIDJOURNEY_RELAX_LIMIT("midjourney:relax:limit:", "midjourney relax次数", 60 * 60 * 48L),
  764. MIDJOURNEY_EXPIRE_TIME("midjourney:expire:time:", "midjourney expire time", 60 * 60 * 48L),
  765. MIDJOURNEY_USER("midjourney:user:", "midjourney user", 60 * 60 * 2L),
  766. MIDJOURNEY_ACCOUNT("midjourney:account:", "midjourney account", 60 * 60 * 48L),
  767. APPLY_MONEY_DAY_LIMIT_KEY("apply_money_day_limit_key:%s:%s:%s", "每日提现次数限制", 60 * 60 * 24L),
  768. NETFLIX_UPDATE_LIMIT_TIME("netflix_update_limit_time", "奈飞同步更新", 30l),
  769. NETFLIX_SET_LIMIT_TIME("netflix_set_limit_time", "奈飞设置限制", 30l),
  770. MIDJOURNEY_CAR_TASK("midjourney:car:task","midjourney car 任务数", 48 * 60 * 60L),
  771. SYS_CONFIG_CACHE_KEY("sys_config_cache_key:", "系统配置缓存key", 60 * 60 * 23L),
  772. NF_UPGRAD_USER_LIMIT_KEY("nf_upgrad_user_limit_key:%s:%s:%s", "奈飞同步装置key", 60 * 60L),
  773. LUMA_USER("luma_user:", "luma_user", 60 * 60 * 2L),
  774. LUMA_NUM_LIMIT("luma_num_limit:", "luma次数", 60 * 60 * 48L),
  775. NF_SET_TIME_LIMIT("nf_set_time_limit:", "设置pin码", 60l),
  776. NF_KICKOUT_TIME_LIMIT("nf_kickout_time_limit:", "踢出奈飞设备", 60l),
  777. GOODS_WHOLESALE_KEY("yh_home_paghe_cache:wholesale_key", "平台批发", 60 * 60 * 4L),
  778. USER_BENEFITS_KEY("yh_home_paghe_cache:user_benefits_key", "用户权益", 60 * 60 * 12L),
  779. USER_MIRROR_SHOP_BACK_LOGIN_KEY("user_mirror_shop_back_login:", "镜像店铺主后台key", 3 * 60),
  780. USER_MIRROR_SHOP_AUTH_SUCCESS_KEY("user_mirror_shop_auth_success_key:%s", "镜像店铺主后台微信授权", 60 * 10),
  781. USER_MIRROR_SHOP_ADVERTISE_CACHE_KEY("user_mirror_shop_advertise_cache_key:", "用户镜像店铺广告缓存key", 60 * 60 * 12),
  782. NETFLIX_CHANGE_TICKET_KEY("netflix_change_ticket_key:", "奈飞更换车票key", 60l),
  783. CORP_KF_ACCOUNT_URL("corp_kf_account_url:", "微信客服url:", 60 * 60 * 6),
  784. ;
  785. private String name;
  786. private String desc;
  787. private long timeout;
  788. public String getNameFormat(Object ... str) {
  789. return String.format(this.getName(), str);
  790. }
  791. }
  792. }