本文整理汇总了Golang中tools/cache.LRUCache.Capacity方法的典型用法代码示例。如果您正苦于以下问题:Golang LRUCache.Capacity方法的具体用法?Golang LRUCache.Capacity怎么用?Golang LRUCache.Capacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools/cache.LRUCache
的用法示例。
在下文中一共展示了LRUCache.Capacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Settings
// Function serialize sub command of stats "settings"
func (s *ServerStat) Settings(storage *cache.LRUCache) map[string]string {
dict := make(map[string]string)
dict["maxbytes"] = tools.IntToString(storage.Capacity())
dict["maxconns"] = tools.IntToString(int64(s.Connections_limit))
dict["tcpport"] = s.tcp
dict["udpport"] = s.udp
dict["verbosity"] = tools.IntToString(int64(s.verbosity))
dict["num_goroutines"] = tools.IntToString(int64(runtime.NumGoroutine()))
dict["evictions"] = "on" //TODO: to think about apportunity of another value.
if storage.Crawler.Enabled() {
dict["lru_crawler"] = "true"
} else {
dict["lru_crawler"] = "false"
}
dict["lru_crawler_sleep"] = tools.IntToString(int64(storage.Crawler.Sleep()))
dict["lru_crawler_tocrawl"] = tools.IntToString(int64(storage.Crawler.ItemsPerRun))
if s.cas_disabled {
dict["cas_enabled"] = "false"
} else {
dict["cas_enabled"] = "true"
}
if s.flush_disabled {
dict["flush_all_enabled"] = "false"
} else {
dict["flush_all_enabled"] = "true"
}
return dict
}
示例2: Serialize
// Function serialize statistic of server and storage and returns it as map of strings
func (s *ServerStat) Serialize(storage *cache.LRUCache) map[string]string {
dict := make(map[string]string)
dict["pid"] = tools.IntToString(int64(s.pid))
dict["uptime"] = tools.IntToString(int64(s.uptime()))
dict["time"] = tools.IntToString(int64(s.time()))
dict["version"] = tools.VERSION
dict["pointer_size"] = tools.IntToString(int64(pointer_size))
secu, mcsecu, secs, mcsecs := s.rusage()
dict["rusage_user"] = tools.IntToString(secu) + "." + tools.IntToString(mcsecu)
dict["rusage_system"] = tools.IntToString(secs) + "." + tools.IntToString(mcsecs)
dict["curr_items"] = tools.IntToString(int64(storage.Stats.Current_items))
dict["total_items"] = tools.IntToString(int64(storage.Stats.Total_items))
dict["bytes"] = tools.IntToString(s.bytes(storage.Capacity()))
dict["curr_connections"] = tools.IntToString(int64(s.Current_connections))
dict["total_connections"] = tools.IntToString(int64(s.Total_connections))
dict["evictions"] = tools.IntToString(int64(storage.Stats.Evictions))
dict["expired_unfetched"] = tools.IntToString(int64(storage.Stats.Expired_unfetched))
dict["evicted_unfetched"] = tools.IntToString(int64(storage.Stats.Evicted_unfetched))
dict["bytes_read"] = tools.IntToString(int64(s.Read_bytes))
dict["bytes_written"] = tools.IntToString(int64(s.Written_bytes))
dict["goroutines"] = tools.IntToString(int64(runtime.NumGoroutine()))
dict["crawler_reclaimed"] = tools.IntToString(storage.Stats.Crawler_reclaimed)
for key, value := range s.Commands {
dict[key] = tools.IntToString(int64(value))
}
return dict
}