123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package dao
- import (
- "context"
- "fmt"
- "go-common/library/cache/memcache"
- "go-common/library/log"
- )
- const (
- _fmtSubtitle = "s_subtitle_%d_%d"
- _fmtVideoSubtitle = "s_video_%d_%d"
- _fmtSubtitleDraft = "s_draft_%v_%v_%v_%v"
- )
- func (d *Dao) subtitleKey(oid int64, subtitleID int64) string {
- return fmt.Sprintf(_fmtSubtitle, oid, subtitleID)
- }
- func (d *Dao) subtitleVideoKey(oid int64, tp int32) string {
- return fmt.Sprintf(_fmtVideoSubtitle, oid, tp)
- }
- func (d *Dao) subtitleDraftKey(oid int64, tp int32, mid int64, lan uint8) string {
- return fmt.Sprintf(_fmtSubtitleDraft, oid, tp, mid, lan)
- }
- // DelVideoSubtitleCache .
- func (d *Dao) DelVideoSubtitleCache(c context.Context, oid int64, tp int32) (err error) {
- var (
- key = d.subtitleVideoKey(oid, tp)
- conn = d.subtitleMc.Get(c)
- )
- defer conn.Close()
- if err = conn.Delete(key); err != nil {
- if err == memcache.ErrNotFound {
- err = nil
- } else {
- log.Error("memcache.Delete(%s) error(%v)", key, err)
- }
- }
- return
- }
- // DelSubtitleDraftCache .
- func (d *Dao) DelSubtitleDraftCache(c context.Context, oid int64, tp int32, mid int64, lan uint8) (err error) {
- var (
- key = d.subtitleDraftKey(oid, tp, mid, lan)
- conn = d.subtitleMc.Get(c)
- )
- defer conn.Close()
- if err = conn.Delete(key); err != nil {
- if err == memcache.ErrNotFound {
- err = nil
- } else {
- log.Error("memcache.Delete(%s) error(%v)", key, err)
- }
- }
- return
- }
- // DelSubtitleCache .
- func (d *Dao) DelSubtitleCache(c context.Context, oid int64, subtitleID int64) (err error) {
- var (
- key = d.subtitleKey(oid, subtitleID)
- conn = d.subtitleMc.Get(c)
- )
- defer conn.Close()
- if err = conn.Delete(key); err != nil {
- if err == memcache.ErrNotFound {
- err = nil
- } else {
- log.Error("memcache.Delete(%s) error(%v)", key, err)
- }
- }
- return
- }
|