mc.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "hash/crc32"
  6. "strconv"
  7. "go-common/app/interface/main/dm2/model"
  8. "go-common/library/cache/memcache"
  9. "go-common/library/log"
  10. )
  11. var (
  12. _lockvalue = []byte("1")
  13. )
  14. const (
  15. _prefixPubLock = "dm_pub_"
  16. _prefixCharPubLock = "dm_pub_char_"
  17. _prefixXML = "dm_xml_"
  18. _prefixSub = "s_"
  19. _prefixAjax = "dm_ajax_"
  20. _prefixDMJudge = "dm_judge_%d_%d_%d"
  21. _prefixDMLimit = "dm_limit_"
  22. _prefixAdvanceCmt = "cache:AdvanceComment:%d@%d.%s"
  23. _prefixAdvLock = "adv_lock_"
  24. _prefixAdvance = "cache:AdvanceComment:"
  25. _prefixHis = "dm_his_%d_%d_%d"
  26. _prefixHisIdx = "dm_his_idx_%d_%d_%s"
  27. _prefixDMMask = "dm_mask_%d_%d_%d"
  28. )
  29. func keyMsgPubLock(mid, color, rnd int64, mode, fontsize int32, ip, msg string) string {
  30. crcStr := fmt.Sprintf("%d_%s_%s_%d_%d_%d_%d", mid, msg, ip, fontsize, color, mode, rnd)
  31. return _prefixPubLock + fmt.Sprint(crc32.ChecksumIEEE([]byte(crcStr)))
  32. }
  33. func keyOidPubLock(mid, oid int64, ip string) string {
  34. crcStr := fmt.Sprintf("%d_%s_%d", mid, ip, oid)
  35. return _prefixPubLock + fmt.Sprint(crc32.ChecksumIEEE([]byte(crcStr)))
  36. }
  37. func keyPubCntLock(mid, color int64, mode, fontsize int32, ip, msg string) string {
  38. crcStr := fmt.Sprintf("%d_%s_%s_%d_%d_%d", mid, msg, ip, fontsize, color, mode)
  39. return _prefixPubLock + fmt.Sprint(crc32.ChecksumIEEE([]byte(crcStr)))
  40. }
  41. func keyCharPubLock(mid, oid int64) string {
  42. return _prefixCharPubLock + fmt.Sprintf("%d_%d", mid, oid)
  43. }
  44. func keyXML(oid int64) string {
  45. return _prefixXML + strconv.FormatInt(oid, 10)
  46. }
  47. func keySubject(tp int32, oid int64) string {
  48. return _prefixSub + fmt.Sprintf("%d_%d", tp, oid)
  49. }
  50. func keyAjax(oid int64) string {
  51. return _prefixAjax + strconv.FormatInt(oid, 10)
  52. }
  53. func keyJudge(tp int8, oid, dmid int64) string {
  54. return fmt.Sprintf(_prefixDMJudge, tp, oid, dmid)
  55. }
  56. func keyDMLimitMid(mid int64) string {
  57. return _prefixDMLimit + strconv.FormatInt(mid, 10)
  58. }
  59. func keyAdvanceCmt(mid, oid int64, mode string) string {
  60. return fmt.Sprintf(_prefixAdvanceCmt, mid, oid, mode)
  61. }
  62. func keyAdvLock(mid, cid int64) string {
  63. return _prefixAdvLock + strconv.FormatInt(mid, 10) + "_" + strconv.FormatInt(cid, 10)
  64. }
  65. func keyHistory(tp int32, oid, timestamp int64) string {
  66. return fmt.Sprintf(_prefixHis, tp, oid, timestamp)
  67. }
  68. func keyHistoryIdx(tp int32, oid int64, month string) string {
  69. return fmt.Sprintf(_prefixHisIdx, tp, oid, month)
  70. }
  71. func keyDMMask(tp int32, oid int64, plat int8) string {
  72. return fmt.Sprintf(_prefixDMMask, tp, oid, plat)
  73. }
  74. // SubjectCache get subject from memcache.
  75. func (d *Dao) SubjectCache(c context.Context, tp int32, oid int64) (sub *model.Subject, err error) {
  76. var (
  77. conn = d.dmMC.Get(c)
  78. key = keySubject(tp, oid)
  79. rp *memcache.Item
  80. )
  81. defer conn.Close()
  82. if rp, err = conn.Get(key); err != nil {
  83. if err == memcache.ErrNotFound {
  84. PromCacheMiss("dm_subject", 1)
  85. sub = nil
  86. err = nil
  87. } else {
  88. log.Error("mc.Get(%s) error(%v)", key, err)
  89. }
  90. return
  91. }
  92. sub = &model.Subject{}
  93. PromCacheHit("dm_subject", 1)
  94. if err = conn.Scan(rp, &sub); err != nil {
  95. log.Error("mc.Scan() error(%v)", err)
  96. }
  97. return
  98. }
  99. // SubjectsCache multi get subject from memcache.
  100. func (d *Dao) SubjectsCache(c context.Context, tp int32, oids []int64) (cached map[int64]*model.Subject, missed []int64, err error) {
  101. var (
  102. conn = d.dmMC.Get(c)
  103. keys []string
  104. oidMap = make(map[string]int64)
  105. )
  106. cached = make(map[int64]*model.Subject)
  107. defer conn.Close()
  108. for _, oid := range oids {
  109. k := keySubject(tp, oid)
  110. if _, ok := oidMap[k]; !ok {
  111. keys = append(keys, k)
  112. oidMap[k] = oid
  113. }
  114. }
  115. rs, err := conn.GetMulti(keys)
  116. if err != nil {
  117. log.Error("conn.GetMulti(%v) error(%v)", keys, err)
  118. return
  119. }
  120. for k, r := range rs {
  121. sub := &model.Subject{}
  122. if err = conn.Scan(r, sub); err != nil {
  123. log.Error("conn.Scan(%s) error(%v)", r.Value, err)
  124. err = nil
  125. continue
  126. }
  127. cached[oidMap[k]] = sub
  128. // delete hit key
  129. delete(oidMap, k)
  130. }
  131. // missed key
  132. missed = make([]int64, 0, len(oidMap))
  133. for _, oid := range oidMap {
  134. missed = append(missed, oid)
  135. }
  136. PromCacheHit("dm_subjects", int64(len(cached)))
  137. PromCacheMiss("dm_subjects", int64(len(missed)))
  138. return
  139. }
  140. // AddSubjectCache add subject cache.
  141. func (d *Dao) AddSubjectCache(c context.Context, sub *model.Subject) (err error) {
  142. var (
  143. conn = d.dmMC.Get(c)
  144. key = keySubject(sub.Type, sub.Oid)
  145. )
  146. defer conn.Close()
  147. item := &memcache.Item{
  148. Key: key,
  149. Object: sub,
  150. Flags: memcache.FlagJSON,
  151. Expiration: d.subjectExpire,
  152. }
  153. if err = conn.Set(item); err != nil {
  154. log.Error("conn.Set(%v) error(%v)", item, err)
  155. }
  156. return
  157. }
  158. // DelXMLCache delete xml content.
  159. func (d *Dao) DelXMLCache(c context.Context, oid int64) (err error) {
  160. conn := d.dmMC.Get(c)
  161. if err = conn.Delete(keyXML(oid)); err != nil {
  162. if err == memcache.ErrNotFound {
  163. err = nil
  164. } else {
  165. log.Error("conn.Delete(%s) error(%v)", keyXML(oid), err)
  166. }
  167. }
  168. conn.Close()
  169. return
  170. }
  171. // AddXMLCache add xml content to memcache.
  172. func (d *Dao) AddXMLCache(c context.Context, oid int64, value []byte) (err error) {
  173. conn := d.dmMC.Get(c)
  174. defer conn.Close()
  175. item := &memcache.Item{
  176. Key: keyXML(oid),
  177. Value: value,
  178. Expiration: d.dmExpire,
  179. }
  180. if err = conn.Set(item); err != nil {
  181. log.Error("conn.Set(%s) error(%v)", keyXML(oid), err)
  182. }
  183. return
  184. }
  185. // XMLCache get xml content.
  186. func (d *Dao) XMLCache(c context.Context, oid int64) (data []byte, err error) {
  187. key := keyXML(oid)
  188. conn := d.dmMC.Get(c)
  189. defer conn.Close()
  190. item, err := conn.Get(key)
  191. if err != nil {
  192. if err == memcache.ErrNotFound {
  193. err = nil
  194. PromCacheMiss("dm_xml", 1)
  195. } else {
  196. log.Error("mc.Get(%s) error(%v)", key, err)
  197. }
  198. return
  199. }
  200. PromCacheHit("dm_xml", 1)
  201. data = item.Value
  202. return
  203. }
  204. // AjaxDMCache get ajax dm from memcache.
  205. func (d *Dao) AjaxDMCache(c context.Context, oid int64) (msgs []string, err error) {
  206. conn := d.dmMC.Get(c)
  207. defer conn.Close()
  208. key := keyAjax(oid)
  209. msgs = make([]string, 0)
  210. item, err := conn.Get(key)
  211. if err != nil {
  212. if err == memcache.ErrNotFound {
  213. err = nil
  214. PromCacheMiss("dm_ajax", 1)
  215. } else {
  216. log.Error("conn.Get(%s) error(%v)", key, err)
  217. }
  218. return
  219. }
  220. PromCacheHit("dm_ajax", 1)
  221. if err = conn.Scan(item, &msgs); err != nil {
  222. log.Error("conn.Scan(%v) error(%v)", item, err)
  223. }
  224. return
  225. }
  226. // AddAjaxDMCache set ajax dm to memcache.
  227. func (d *Dao) AddAjaxDMCache(c context.Context, oid int64, msgs []string) (err error) {
  228. conn := d.dmMC.Get(c)
  229. defer conn.Close()
  230. key := keyAjax(oid)
  231. item := &memcache.Item{Key: key, Object: msgs, Flags: memcache.FlagJSON, Expiration: d.ajaxExpire}
  232. if err = conn.Set(item); err != nil {
  233. log.Error("conn.Set(%v) error(%v)", item, err)
  234. }
  235. return
  236. }
  237. // SetDMJudgeCache dm fengjiwei list
  238. func (d *Dao) SetDMJudgeCache(c context.Context, tp int8, oid, dmid int64, l *model.JudgeDMList) (err error) {
  239. key := keyJudge(tp, oid, dmid)
  240. conn := d.dmMC.Get(c)
  241. defer conn.Close()
  242. item := memcache.Item{
  243. Key: key,
  244. Object: l,
  245. Expiration: 86400 * 30,
  246. Flags: memcache.FlagJSON,
  247. }
  248. if err = conn.Set(&item); err != nil {
  249. log.Error("DMJudge:mc.Set(%v) error(%v)", item, err)
  250. }
  251. return
  252. }
  253. // DMJudgeCache memcache cache of dm judge list.
  254. func (d *Dao) DMJudgeCache(c context.Context, tp int8, oid, dmid int64) (l *model.JudgeDMList, err error) {
  255. key := keyJudge(tp, oid, dmid)
  256. conn := d.dmMC.Get(c)
  257. defer conn.Close()
  258. item, err := conn.Get(key)
  259. if err != nil {
  260. if err == memcache.ErrNotFound {
  261. err = nil
  262. l = nil
  263. PromCacheMiss("dm_judge", 1)
  264. } else {
  265. log.Error("mc.Get(key:%s) error(%v)", key, err)
  266. }
  267. return
  268. }
  269. PromCacheHit("dm_judge", 1)
  270. if err = conn.Scan(item, &l); err != nil {
  271. log.Error("conn.Scan(%v) error(%v)", item, err)
  272. }
  273. return
  274. }
  275. // AddMsgPubLock set publock into memcache
  276. func (d *Dao) AddMsgPubLock(c context.Context, mid, color, rnd int64, mode, fontsize int32, ip, msg string) (err error) {
  277. conn := d.dmMC.Get(c)
  278. item := memcache.Item{
  279. Key: keyMsgPubLock(mid, color, rnd, mode, fontsize, ip, msg),
  280. Value: _lockvalue,
  281. Expiration: 300,
  282. Flags: memcache.FlagRAW,
  283. }
  284. if err = conn.Set(&item); err != nil {
  285. log.Error("mc.Set(%v) error(%v)", item, err)
  286. }
  287. conn.Close()
  288. return
  289. }
  290. // MsgPublock get publock
  291. func (d *Dao) MsgPublock(c context.Context, mid, color, rnd int64, mode, fontsize int32, ip, msg string) (cached bool, err error) {
  292. conn := d.dmMC.Get(c)
  293. defer conn.Close()
  294. key := keyMsgPubLock(mid, color, rnd, mode, fontsize, ip, msg)
  295. if _, err = conn.Get(key); err != nil {
  296. if err == memcache.ErrNotFound {
  297. cached = false
  298. err = nil
  299. } else {
  300. log.Error("mc.Get(%s) error(%v)", key, err)
  301. }
  302. return
  303. }
  304. cached = true
  305. return
  306. }
  307. // AddOidPubLock set publock into memcache
  308. func (d *Dao) AddOidPubLock(c context.Context, mid, oid int64, ip string) (err error) {
  309. conn := d.dmMC.Get(c)
  310. item := memcache.Item{
  311. Key: keyOidPubLock(mid, oid, ip),
  312. Value: _lockvalue,
  313. Expiration: 4,
  314. Flags: memcache.FlagRAW,
  315. }
  316. if err = conn.Set(&item); err != nil {
  317. log.Error("mc.Set(%v) error(%v)", item, err)
  318. }
  319. conn.Close()
  320. return
  321. }
  322. // OidPubLock get publock
  323. func (d *Dao) OidPubLock(c context.Context, mid, oid int64, ip string) (cached bool, err error) {
  324. conn := d.dmMC.Get(c)
  325. defer conn.Close()
  326. key := keyOidPubLock(mid, oid, ip)
  327. if _, err = conn.Get(key); err != nil {
  328. if err == memcache.ErrNotFound {
  329. cached = false
  330. err = nil
  331. } else {
  332. log.Error("mc.Get(%s) error(%v)", key, err)
  333. }
  334. return
  335. }
  336. cached = true
  337. return
  338. }
  339. // AddDMLimitCache add Dmlimit in cache
  340. func (d *Dao) AddDMLimitCache(c context.Context, mid int64, limiter *model.Limiter) (err error) {
  341. var (
  342. conn = d.dmMC.Get(c)
  343. key = keyDMLimitMid(mid)
  344. )
  345. defer conn.Close()
  346. item := &memcache.Item{
  347. Key: key,
  348. Object: limiter,
  349. Flags: memcache.FlagJSON,
  350. Expiration: 600,
  351. }
  352. if err = conn.Set(item); err != nil {
  353. log.Error("conn.Set(%v) error(%v)", item, err)
  354. }
  355. return
  356. }
  357. // DMLimitCache get dm limit from memcache.
  358. func (d *Dao) DMLimitCache(c context.Context, mid int64) (limiter *model.Limiter, err error) {
  359. var (
  360. conn = d.dmMC.Get(c)
  361. key = keyDMLimitMid(mid)
  362. rp *memcache.Item
  363. )
  364. limiter = &model.Limiter{}
  365. defer conn.Close()
  366. if rp, err = conn.Get(key); err != nil {
  367. if err == memcache.ErrNotFound {
  368. limiter = nil
  369. err = nil
  370. } else {
  371. log.Error("mc.Get(%s) error(%v)", key, err)
  372. }
  373. return
  374. }
  375. if err = conn.Scan(rp, &limiter); err != nil {
  376. log.Error("mc.Scan() error(%v)", err)
  377. }
  378. return
  379. }
  380. // AddAdvanceCmtCache return
  381. func (d *Dao) AddAdvanceCmtCache(c context.Context, oid, mid int64, mode string, adv *model.AdvanceCmt) (err error) {
  382. var (
  383. conn = d.filterMC.Get(c)
  384. key = keyAdvanceCmt(mid, oid, mode)
  385. )
  386. defer conn.Close()
  387. item := &memcache.Item{
  388. Key: key,
  389. Object: adv,
  390. Flags: memcache.FlagJSON,
  391. Expiration: d.filterMCExpire,
  392. }
  393. if err = conn.Set(item); err != nil {
  394. log.Error("conn.Set(%v) error(%v)", item, err)
  395. }
  396. return
  397. }
  398. // AdvanceCmtCache return advance comment from memcache.
  399. func (d *Dao) AdvanceCmtCache(c context.Context, oid, mid int64, mode string) (adv *model.AdvanceCmt, err error) {
  400. var (
  401. conn = d.filterMC.Get(c)
  402. key = keyAdvanceCmt(mid, oid, mode)
  403. rp *memcache.Item
  404. )
  405. defer conn.Close()
  406. adv = &model.AdvanceCmt{}
  407. if rp, err = conn.Get(key); err != nil {
  408. if err == memcache.ErrNotFound {
  409. adv = nil
  410. err = nil
  411. PromCacheMiss("dm_advance", 1)
  412. } else {
  413. log.Error("mc.Get(%s) error(%v)", key, err)
  414. }
  415. return
  416. }
  417. PromCacheHit("dm_advance", 1)
  418. if err = conn.Scan(rp, &adv); err != nil {
  419. log.Error("mc.Scan() error(%v)", err)
  420. }
  421. return
  422. }
  423. // AddAdvanceLock 购买高级弹幕锁
  424. func (d *Dao) AddAdvanceLock(c context.Context, mid, cid int64) (succeed bool) {
  425. var (
  426. key = keyAdvLock(mid, cid)
  427. conn = d.filterMC.Get(c)
  428. )
  429. defer conn.Close()
  430. item := &memcache.Item{
  431. Key: key,
  432. Value: []byte("3"),
  433. Expiration: 60,
  434. }
  435. if err := conn.Add(item); err != nil {
  436. succeed = false
  437. log.Error("conn.Add(%s) error(%v)", key, err)
  438. } else {
  439. succeed = true
  440. }
  441. return
  442. }
  443. // DelAdvanceLock 删除购买高级弹幕锁
  444. func (d *Dao) DelAdvanceLock(c context.Context, mid, cid int64) (err error) {
  445. var (
  446. key = keyAdvLock(mid, cid)
  447. conn = d.filterMC.Get(c)
  448. )
  449. if err = conn.Delete(key); err != nil {
  450. if err == memcache.ErrNotFound {
  451. err = nil
  452. } else {
  453. log.Error("conn.Delete(%s) error(%v)", key, err)
  454. }
  455. }
  456. conn.Close()
  457. return
  458. }
  459. // DelAdvCache delete from cache.
  460. func (d *Dao) DelAdvCache(c context.Context, mid, cid int64, mode string) (err error) {
  461. var (
  462. key = _prefixAdvance + strconv.FormatInt(mid, 10) + "@" + strconv.FormatInt(cid, 10) + "." + mode
  463. )
  464. conn := d.filterMC.Get(c)
  465. err = conn.Delete(key)
  466. conn.Close()
  467. if err != nil {
  468. if err == memcache.ErrNotFound {
  469. err = nil
  470. } else {
  471. log.Error("memcache.Delete(%s) error(%v)", key, err)
  472. }
  473. }
  474. return
  475. }
  476. // AddHistoryCache add dm history to memcache.
  477. func (d *Dao) AddHistoryCache(c context.Context, tp int32, oid, timestamp int64, value []byte) (err error) {
  478. var (
  479. conn = d.dmMC.Get(c)
  480. key = keyHistory(tp, oid, timestamp)
  481. )
  482. defer conn.Close()
  483. item := &memcache.Item{
  484. Key: key,
  485. Value: value,
  486. Expiration: d.historyExpire,
  487. }
  488. if err = conn.Set(item); err != nil {
  489. log.Error("conn.Set(%s) error(%v)", key, err)
  490. }
  491. return
  492. }
  493. // HistoryCache history cache.
  494. func (d *Dao) HistoryCache(c context.Context, tp int32, oid, timestamp int64) (data []byte, err error) {
  495. var (
  496. conn = d.dmMC.Get(c)
  497. key = keyHistory(tp, oid, timestamp)
  498. )
  499. defer conn.Close()
  500. item, err := conn.Get(key)
  501. if err != nil {
  502. if err == memcache.ErrNotFound {
  503. err = nil
  504. PromCacheMiss("dm_history", 1)
  505. } else {
  506. log.Error("mc.Get(%s) error(%v)", key, err)
  507. }
  508. return
  509. }
  510. PromCacheHit("dm_history", 1)
  511. data = item.Value
  512. return
  513. }
  514. // AddHisIdxCache add dm history date index to memcache.
  515. func (d *Dao) AddHisIdxCache(c context.Context, tp int32, oid int64, month string, dates []string) (err error) {
  516. var (
  517. conn = d.dmMC.Get(c)
  518. key = keyHistoryIdx(tp, oid, month)
  519. )
  520. defer conn.Close()
  521. item := &memcache.Item{
  522. Key: key,
  523. Object: dates,
  524. Flags: memcache.FlagJSON,
  525. Expiration: d.historyExpire,
  526. }
  527. if err = conn.Set(item); err != nil {
  528. log.Error("conn.Set(%s) error(%v)", key, err)
  529. }
  530. return
  531. }
  532. // HistoryIdxCache get history date index.
  533. func (d *Dao) HistoryIdxCache(c context.Context, tp int32, oid int64, month string) (dates []string, err error) {
  534. var (
  535. conn = d.dmMC.Get(c)
  536. key = keyHistoryIdx(tp, oid, month)
  537. )
  538. defer conn.Close()
  539. item, err := conn.Get(key)
  540. if err != nil {
  541. if err == memcache.ErrNotFound {
  542. err = nil
  543. PromCacheMiss("dm_history_index", 1)
  544. } else {
  545. log.Error("mc.Get(%s) error(%v)", key, err)
  546. }
  547. return
  548. }
  549. PromCacheHit("dm_history_index", 1)
  550. if err = conn.Scan(item, &dates); err != nil {
  551. log.Error("conn.Scan(%+v) error(%v)", item, err)
  552. }
  553. return
  554. }
  555. // DMMaskCache get dm mask cache
  556. func (d *Dao) DMMaskCache(c context.Context, tp int32, oid int64, plat int8) (mask *model.Mask, err error) {
  557. var (
  558. conn = d.dmMC.Get(c)
  559. key = keyDMMask(tp, oid, plat)
  560. item *memcache.Item
  561. )
  562. defer conn.Close()
  563. if item, err = conn.Get(key); err != nil {
  564. if err == memcache.ErrNotFound {
  565. err = nil
  566. mask = nil
  567. PromCacheMiss("dm_mask", 1)
  568. } else {
  569. log.Error("mc.Get(%s) error(%v)", key, err)
  570. }
  571. return
  572. }
  573. mask = &model.Mask{}
  574. PromCacheHit("dm_mask", 1)
  575. if err = conn.Scan(item, &mask); err != nil {
  576. log.Error("conn.Scan(%+v) error(%v)", item, err)
  577. }
  578. return
  579. }
  580. // AddMaskCache add dm mask cache
  581. func (d *Dao) AddMaskCache(c context.Context, tp int32, mask *model.Mask) (err error) {
  582. var (
  583. conn = d.dmMC.Get(c)
  584. key = keyDMMask(tp, mask.Cid, mask.Plat)
  585. )
  586. defer conn.Close()
  587. item := &memcache.Item{
  588. Key: key,
  589. Object: mask,
  590. Flags: memcache.FlagJSON,
  591. Expiration: d.dmMaskExpire,
  592. }
  593. if err = conn.Set(item); err != nil {
  594. log.Error("conn.Set(%+v) error(%v)", item, err)
  595. }
  596. return
  597. }