本文整理汇总了Golang中github.com/shingetsu-gou/shingetsu-gou/thread.Cache.Stamp方法的典型用法代码示例。如果您正苦于以下问题:Golang Cache.Stamp方法的具体用法?Golang Cache.Stamp怎么用?Golang Cache.Stamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/shingetsu-gou/shingetsu-gou/thread.Cache
的用法示例。
在下文中一共展示了Cache.Stamp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: appendRSS
//appendRSS appends cache ca to rss with contents,url to records,stamp,attached file.
func (g *gatewayCGI) appendRSS(rsss *cgi.RSS, ca *thread.Cache) {
now := time.Now().Unix()
if ca.Stamp()+cfg.RSSRange < now {
return
}
title := util.Escape(util.FileDecode(ca.Datfile))
path := cfg.ThreadURL + "/" + util.StrEncode(title)
recs := ca.LoadRecords(record.Alive)
for _, r := range recs {
if r.Stamp+cfg.RSSRange < now {
continue
}
if err := r.Load(); err != nil {
log.Println(err)
continue
}
desc := cgi.RSSTextFormat(r.GetBodyValue("body", ""))
content := g.rssHTMLFormat(r.GetBodyValue("body", ""), cfg.ThreadURL, title)
if attach := r.GetBodyValue("attach", ""); attach != "" {
suffix := r.GetBodyValue("suffix", "")
if reg := regexp.MustCompile("^[0-9A-Za-z]+$"); !reg.MatchString(suffix) {
suffix = cfg.SuffixTXT
}
content += fmt.Sprintf("\n <p><a href=\"http://%s%s%s%s/%s/%d.%s\">%d.%s</a></p>",
g.Host(), cfg.ThreadURL, "/", ca.Datfile, r.ID, r.Stamp, suffix, r.Stamp, suffix)
}
permpath := fmt.Sprintf("%s/%s", path[1:], r.ID[:8])
rsss.Append(permpath, title, cgi.RSSTextFormat(r.GetBodyValue("name", "")), desc, content, user.GetStrings(ca.Datfile), r.Stamp, false)
}
}
示例2: makeOneRow
//makeOneRow makes one row of CSV depending on c.
func (g *gatewayCGI) makeOneRow(c string, ca *thread.Cache, p, title string) string {
switch c {
case "file":
return ca.Datfile
case "stamp":
return strconv.FormatInt(ca.Stamp(), 10)
case "date":
return time.Unix(ca.Stamp(), 0).String()
case "path":
return p
case "uri":
if g.Host() != "" && p != "" {
return "http://" + g.Host() + p
}
case "type":
return "thread"
case "title":
return title
case "records":
return strconv.Itoa(ca.Len())
case "size":
return strconv.FormatInt(ca.Size(), 10)
case "tag":
return user.String(ca.Datfile)
case "sugtag":
return suggest.String(ca.Datfile)
}
return ""
}
示例3: bg
//bg waits for at least one record in the cache.
func bg(c *thread.Cache, wg *sync.WaitGroup) {
w := 2 * time.Second
newest, err := recentlist.Newest(c.Datfile)
var done chan struct{}
go func() {
wg.Wait()
done <- struct{}{}
}()
if err == nil && (newest.Stamp == c.Stamp()) {
return
}
for {
select {
case <-done:
return
case <-time.After(w):
w += time.Second
if c.HasRecord() || w >= 5*time.Second {
return
}
}
}
}