func CachedShortUrlBySlug(slug string) (*ShortUrl, error) { k := fmt.Sprintf("shorturl:%s:url", slug) data, err := redis.Client.Get(k) if err == nil { s := ShortUrl{Slug: slug, URL: string(data)} return &s, nil } id := key.GenId(slug) revel.WARN.Printf("Missed cache for slug %v (id %v, key %v)", slug, id, k) s, err := ShortUrlById(id) if s != nil && err == nil { go s.pushToRedis() } return s, err }
func ShortUrlBySlug(slug string) (*ShortUrl, error) { id := key.GenId(slug) return ShortUrlById(id) }