本文整理汇总了Golang中github.com/shingetsu-gou/shingetsu-gou/thread.Cache.Len方法的典型用法代码示例。如果您正苦于以下问题:Golang Cache.Len方法的具体用法?Golang Cache.Len怎么用?Golang Cache.Len使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/shingetsu-gou/shingetsu-gou/thread.Cache
的用法示例。
在下文中一共展示了Cache.Len方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: printPageNavi
//printPageNavi renders page_navi.txt, part for paging.
func (t *threadCGI) printPageNavi(path string, page int, ca *thread.Cache, id string) {
len := ca.Len()
first := len / cfg.ThreadPageSize
if len%cfg.ThreadPageSize == 0 {
first++
}
pages := make([]int, first+1)
for i := 0; i <= first; i++ {
pages[i] = i
}
s := struct {
Page int
CacheLen int
Path string
ID string
First int
ThreadCGI string
Message cgi.Message
ThreadPageSize int
Pages []int
}{
page,
len,
path,
id,
first,
cfg.ThreadURL,
t.M,
cfg.ThreadPageSize,
pages,
}
cgi.RenderTemplate("page_navi", s, t.WR)
}
示例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: NewResTable
//NewResTable creates ane returns a resTable instance.
func NewResTable(ca *thread.Cache) *ResTable {
r := &ResTable{
make(map[string]int),
make([]string, ca.Len()+1),
}
recs := ca.LoadRecords(record.Alive)
for i, k := range recs.Keys() {
rec := recs.Get(k, nil)
r.Num2id[i+1] = rec.ID[:8]
r.ID2num[rec.ID[:8]] = i + 1
}
return r
}