本文整理匯總了Golang中github.com/prataprc/golib/llrb.MemStore.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang MemStore.Get方法的具體用法?Golang MemStore.Get怎麽用?Golang MemStore.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/prataprc/golib/llrb.MemStore
的用法示例。
在下文中一共展示了MemStore.Get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: validate
func validate(
d *llrb.Dict,
rb llrb.MemStore, cmd []interface{}, stats map[string]int) map[string]int {
var ref, val interface{}
name := cmd[0].(string)
switch name {
case "get":
ref = d.Get(&llrb.KeyInt{int64(cmd[1].(float64)), -1})
val = rb.Get(&llrb.KeyInt{int64(cmd[1].(float64)), -1})
case "min":
ref = d.Min()
val = rb.Min()
case "max":
ref = d.Max()
val = rb.Max()
case "delmin":
ref = d.DeleteMin()
val = rb.DeleteMin()
case "delmax":
ref = d.DeleteMax()
val = rb.DeleteMax()
case "upsert":
now := time.Now().UnixNano()
k := &llrb.KeyInt{int64(cmd[1].(float64)), now}
ref = d.Upsert(k)
val = rb.Upsert(k)
case "insert":
now := time.Now().UnixNano()
k := &llrb.KeyInt{int64(cmd[1].(float64)), now}
if rb.Get(k) == nil {
d.Insert(k)
rb.Insert(k)
} else {
cmd[0] = "upsert"
ref = d.Upsert(k)
val = rb.Upsert(k)
}
case "delete":
ref = d.Delete(&llrb.KeyInt{int64(cmd[1].(float64)), -1})
val = rb.Delete(&llrb.KeyInt{int64(cmd[1].(float64)), -1})
default:
log.Fatalf("unknown command %v\n", cmd)
return stats
}
if reflect.DeepEqual(ref, val) == false {
log.Fatalf("expected %v got %v\n", ref, val)
}
stats = compute_stats(cmd, stats)
return stats
}
示例2: benchGet
func benchGet(s llrb.MemStore) {
for _, key := range getInts {
s.Get(key)
}
}