當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ybc.Config類代碼示例

本文整理匯總了Golang中github.com/valyala/ybc/bindings/go/ybc.Config的典型用法代碼示例。如果您正苦於以下問題:Golang Config類的具體用法?Golang Config怎麽用?Golang Config使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Config類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: newBenchClientServerCache_Ext

func newBenchClientServerCache_Ext(buffersSize, osBuffersSize, maxPendingRequestsCount int, b *testing.B) (c *Client, s *Server, cache *ybc.Cache) {
	config := ybc.Config{
		MaxItemsCount: 1000 * 1000,
		DataFileSize:  10 * 1000 * 1000,
	}

	cache, err := config.OpenCache(true)
	if err != nil {
		b.Fatal(err)
	}

	s = &Server{
		Cache:             cache,
		ListenAddr:        testAddr,
		ReadBufferSize:    buffersSize,
		WriteBufferSize:   buffersSize,
		OSReadBufferSize:  osBuffersSize,
		OSWriteBufferSize: osBuffersSize,
	}
	s.Start()

	c = &Client{
		ServerAddr: testAddr,
		ClientConfig: ClientConfig{
			ReadBufferSize:          buffersSize,
			WriteBufferSize:         buffersSize,
			OSReadBufferSize:        osBuffersSize,
			OSWriteBufferSize:       osBuffersSize,
			MaxPendingRequestsCount: maxPendingRequestsCount,
		},
	}
	c.Start()

	return
}
開發者ID:kangkot,項目名稱:ybc,代碼行數:35,代碼來源:perf_test.go

示例2: newCache

func newCache(t *testing.T) *ybc.Cache {
	config := ybc.Config{
		MaxItemsCount: 1000 * 1000,
		DataFileSize:  10 * 1000 * 1000,
	}

	cache, err := config.OpenCache(true)
	if err != nil {
		t.Fatal(err)
	}
	return cache
}
開發者ID:kangkot,項目名稱:ybc,代碼行數:12,代碼來源:client_server_test.go

示例3: newBenchCachingClientServerCache

func newBenchCachingClientServerCache(b *testing.B) (cc *CachingClient, s *Server, cache *ybc.Cache) {
	c, s, cache := newBenchClientServerCache(b)

	config := ybc.Config{
		MaxItemsCount: 1000 * 1000,
		DataFileSize:  10 * 1000 * 1000,
	}

	localCache, err := config.OpenCache(true)
	if err != nil {
		b.Fatal(err)
	}

	cc = &CachingClient{
		Client: c,
		Cache:  localCache,
	}
	return
}
開發者ID:kangkot,項目名稱:ybc,代碼行數:19,代碼來源:perf_test.go

示例4: createCache

func createCache() ybc.Cacher {
	config := ybc.Config{
		MaxItemsCount: ybc.SizeT(*maxItemsCount),
		DataFileSize:  ybc.SizeT(*cacheSize) * ybc.SizeT(1024*1024),
	}

	var err error
	var cache ybc.Cacher

	cacheFilesPath_ := strings.Split(*cacheFilesPath, ",")
	cacheFilesCount := len(cacheFilesPath_)
	logMessage("Opening data files. This can take a while for the first time if files are big")
	if cacheFilesCount < 2 {
		if cacheFilesPath_[0] != "" {
			config.DataFile = cacheFilesPath_[0] + ".cdn-booster.data"
			config.IndexFile = cacheFilesPath_[0] + ".cdn-booster.index"
		}
		cache, err = config.OpenCache(true)
		if err != nil {
			logFatal("Cannot open cache: [%s]", err)
		}
	} else if cacheFilesCount > 1 {
		config.MaxItemsCount /= ybc.SizeT(cacheFilesCount)
		config.DataFileSize /= ybc.SizeT(cacheFilesCount)
		var configs ybc.ClusterConfig
		configs = make([]*ybc.Config, cacheFilesCount)
		for i := 0; i < cacheFilesCount; i++ {
			cfg := config
			cfg.DataFile = cacheFilesPath_[i] + ".cdn-booster.data"
			cfg.IndexFile = cacheFilesPath_[i] + ".cdn-booster.index"
			configs[i] = &cfg
		}
		cache, err = configs.OpenCluster(true)
		if err != nil {
			logFatal("Cannot open cache cluster: [%s]", err)
		}
	}
	logMessage("Data files have been opened")
	return cache
}
開發者ID:valyala,項目名稱:ybc,代碼行數:40,代碼來源:main.go

示例5: main

func main() {
	iniflags.Parse()

	runtime.GOMAXPROCS(*goMaxProcs)

	syncInterval_ := *syncInterval
	if syncInterval_ <= 0 {
		syncInterval_ = ybc.ConfigDisableSync
	}
	config := ybc.Config{
		MaxItemsCount:   ybc.SizeT(*maxItemsCount),
		DataFileSize:    ybc.SizeT(*cacheSize) * ybc.SizeT(1024*1024),
		HotItemsCount:   ybc.SizeT(*hotItemsCount),
		HotDataSize:     ybc.SizeT(*hotDataSize),
		DeHashtableSize: *deHashtableSize,
		SyncInterval:    syncInterval_,
	}

	var cache ybc.Cacher
	var err error

	cacheFilesPath_ := strings.Split(*cacheFilesPath, ",")
	cacheFilesCount := len(cacheFilesPath_)
	log.Printf("Opening data files. This can take a while for the first time if files are big\n")
	if cacheFilesCount < 2 {
		if cacheFilesPath_[0] != "" {
			config.DataFile = cacheFilesPath_[0] + ".go-memcached.data"
			config.IndexFile = cacheFilesPath_[0] + ".go-memcached.index"
		}
		cache, err = config.OpenCache(true)
		if err != nil {
			log.Fatalf("Cannot open cache: [%s]", err)
		}
	} else if cacheFilesCount > 1 {
		config.MaxItemsCount /= ybc.SizeT(cacheFilesCount)
		config.DataFileSize /= ybc.SizeT(cacheFilesCount)
		var configs ybc.ClusterConfig
		configs = make([]*ybc.Config, cacheFilesCount)
		for i := 0; i < cacheFilesCount; i++ {
			cfg := config
			cfg.DataFile = cacheFilesPath_[i] + ".go-memcached.data"
			cfg.IndexFile = cacheFilesPath_[i] + ".go-memcached.index"
			configs[i] = &cfg
		}
		cache, err = configs.OpenCluster(true)
		if err != nil {
			log.Fatalf("Cannot open cache cluster: [%s]", err)
		}
	}
	defer cache.Close()
	log.Printf("Data files have been opened\n")

	s := memcache.Server{
		Cache:             cache,
		ListenAddr:        *listenAddr,
		ReadBufferSize:    *readBufferSize,
		WriteBufferSize:   *writeBufferSize,
		OSReadBufferSize:  *osReadBufferSize,
		OSWriteBufferSize: *osWriteBufferSize,
	}
	log.Printf("Starting the server")
	if err := s.Serve(); err != nil {
		log.Fatalf("Cannot serve traffic: [%s]", err)
	}
}
開發者ID:kangkot,項目名稱:ybc,代碼行數:65,代碼來源:main.go


注:本文中的github.com/valyala/ybc/bindings/go/ybc.Config類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。