示例#1
0
文件: options.go 项目: unigraph/rdb
func optionsBulk(c *cli.Context) error {
	dbOptions := rdb.NewDefaultOptions()
	defaultFlags.setOptions(dbOptions, c)
	out, err := json.MarshalIndent(DefaultOptions, "", "\t")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(out))
	return nil
}
示例#2
0
文件: create.go 项目: unigraph/rdb
func createDb(c *cli.Context) error {
	dbName := c.GlobalString("db")
	if dbName == "" {
		cli.ShowAppHelp(c)
		return nil
	}
	dbOptions := rdb.NewDefaultOptions()
	dbOptions.SetCreateIfMissing(true)
	defaultFlags.setOptions(dbOptions, c)

	db, err := rdb.OpenDb(dbOptions, dbName)
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()
	return nil
}
示例#3
0
文件: stats.go 项目: unigraph/rdb
func statsDb(c *cli.Context) error {
	dbName := c.GlobalString("db")
	if dbName == "" {
		cli.ShowAppHelp(c)
		return nil
	}

	dbOptions := rdb.NewDefaultOptions()
	defaultFlags.setOptions(dbOptions, c)

	db, err := rdb.OpenDbForReadOnly(dbOptions, dbName, false)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(db.GetProperty("rocksdb.stats"))
	db.Close()
	return nil
}
示例#4
0
文件: compact.go 项目: unigraph/rdb
func compactDb(c *cli.Context) error {
	dbName := c.GlobalString("db")
	if dbName == "" {
		cli.ShowAppHelp(c)
		return nil
	}

	dbOptions := rdb.NewDefaultOptions()
	dbOptions.SetCreateIfMissing(true)
	defaultFlags.setOptions(dbOptions, c)

	db, err := rdb.OpenDb(dbOptions, dbName)
	if err != nil {
		log.Fatal(err)
	}
	db.CompactRange(rdb.Range{})
	db.Flush(rdb.NewDefaultFlushOptions())
	fmt.Println(db.GetProperty("rocksdb.stats"))
	fmt.Println("done")
	return nil
}