Example #1
0
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
}
Example #2
0
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
}
Example #3
0
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
}
Example #4
0
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
}