示例#1
0
func NewDiskCacheTransport() *Transport {
	tempDir, err := ioutil.TempDir("", "httpdiskcache")
	if err != nil {
		glog.Errorf("TempDir err = %v", err)
		return nil
	}
	glog.Infof("NewDiskCacheTransport tempDir = %v", tempDir)
	c := diskcache.New(tempDir)
	t := NewTransport(c)
	return t
}
示例#2
0
func NewLeveldbCacheTransport() *Transport {
	tempDir, err := ioutil.TempDir("", "httpleveldbcache")
	if err != nil {
		glog.Errorf("TempDir err = %v", err)
		return nil
	}
	glog.Infof("NewLeveldbCacheTransport tempDir = %v", tempDir)
	c, err := leveldbcache.New(fmt.Sprintf("%s%c%s", tempDir, os.PathSeparator, "db"))
	if err != nil {
		glog.Errorf("New err = %v", err)
		return nil
	}
	t := NewTransport(c)
	return t
}