本文整理汇总了Golang中github.com/valyala/ybc/libs/go/memcache.Item类的典型用法代码示例。如果您正苦于以下问题:Golang Item类的具体用法?Golang Item怎么用?Golang Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Item类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: workerGetSetRand
func workerGetSetRand(client *memcache.Client, wg *sync.WaitGroup, ch <-chan int) {
defer wg.Done()
var item memcache.Item
itemsCount := *requestsCount / *workersCount
for _ = range ch {
n := rand.Intn(itemsCount)
item.Key = []byte(fmt.Sprintf("%s_%d", *key, n))
v := []byte(fmt.Sprintf("%s_%d", *value, n))
if rand.Float32() < 0.5 {
err := client.Get(&item)
if err == memcache.ErrCacheMiss {
continue
}
if err != nil {
log.Fatalf("Error in Client.Get(): [%s]", err)
}
if !bytes.Equal(item.Value, v) {
log.Fatalf("Unexpected value=[%s] obtained. Expected [%s]", item.Value, v)
}
} else {
item.Value = v
if err := client.Set(&item); err != nil {
log.Fatalf("Error in Client.Set(): [%s]", err)
}
}
}
}
开发者ID:inthecloud247,项目名称:ybc,代码行数:27,代码来源:main.go
示例2: workerGetSetNew
func workerGetSetNew(client memcache_new.Cacher, wg *sync.WaitGroup, ch <-chan int, stats *Stats) {
defer wg.Done()
var item memcache_new.Item
for _ = range ch {
n := rand.Intn(*itemsCount)
item.Key = []byte(fmt.Sprintf("%s_%d", key, n))
startTime := time.Now()
if rand.Float64() < *getRatio {
err := client.Get(&item)
if err == memcache_new.ErrCacheMiss {
stats.cacheMissCount++
continue
}
if err != nil {
stats.errorsCount++
continue
}
stats.cacheHitCount++
updateResponseTimeHistogram(stats, startTime)
} else {
item.Value = value
if err := client.Set(&item); err != nil {
stats.errorsCount++
continue
}
updateResponseTimeHistogram(stats, startTime)
}
}
}
开发者ID:jjoergensen,项目名称:ybc,代码行数:29,代码来源:main.go
示例3: precreateItemsNew
func precreateItemsNew(client memcache_new.Cacher) {
item := memcache_new.Item{
Value: value,
}
for i := 0; i < *itemsCount; i++ {
item.Key = []byte(fmt.Sprintf("%s_%d", key, i))
client.SetNowait(&item)
}
}
开发者ID:jjoergensen,项目名称:ybc,代码行数:9,代码来源:main.go
示例4: workerSet
func workerSet(client *memcache.Client, wg *sync.WaitGroup, ch <-chan int) {
defer wg.Done()
var item memcache.Item
for i := range ch {
item.Key = []byte(fmt.Sprintf("%s_%d", *key, i))
item.Value = []byte(fmt.Sprintf("%s_%d", *value, i))
if err := client.Set(&item); err != nil {
log.Fatalf("Error in Client.Set(): [%s]", err)
}
}
}
开发者ID:inthecloud247,项目名称:ybc,代码行数:11,代码来源:main.go
示例5: workerSetNew
func workerSetNew(client memcache_new.Cacher, wg *sync.WaitGroup, ch <-chan int, stats *Stats) {
defer wg.Done()
var item memcache_new.Item
for _ = range ch {
n := rand.Intn(*itemsCount)
item.Key = []byte(fmt.Sprintf("%s_%d", key, n))
item.Value = value
startTime := time.Now()
if err := client.Set(&item); err != nil {
stats.errorsCount++
continue
}
updateResponseTimeHistogram(stats, startTime)
}
}
开发者ID:jjoergensen,项目名称:ybc,代码行数:15,代码来源:main.go
示例6: workerGetHit
func workerGetHit(client *memcache.Client, wg *sync.WaitGroup, ch <-chan int) {
defer wg.Done()
item := memcache.Item{
Key: []byte(*key),
Value: []byte(*value),
}
valueOrig := item.Value
item.Value = nil
for _ = range ch {
if err := client.Get(&item); err != nil {
log.Fatalf("Error in Client.Get(): [%s]", err)
}
if !bytes.Equal(valueOrig, item.Value) {
log.Fatalf("Unexpected value read=[%s]. Expected=[%s]", item.Value, valueOrig)
}
}
}
开发者ID:inthecloud247,项目名称:ybc,代码行数:17,代码来源:main.go
注:本文中的github.com/valyala/ybc/libs/go/memcache.Item类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论