func ExampleBucket_PutNX() {
	bx, _ := buckets.Open(tempfile())
	defer os.Remove(bx.Path())
	defer bx.Close()

	// Create a new `things` bucket.
	bucket := []byte("things")
	things, _ := bx.New(bucket)

	// Put key/value into the `things` bucket.
	key, value := []byte("A"), []byte("alpha")
	if err := things.Put(key, value); err != nil {
		fmt.Printf("could not insert item: %v", err)
	}

	// Read value back in a different read-only transaction.
	got, _ := things.Get(key)

	fmt.Printf("The value of %q in `%s` is %q\n", key, bucket, got)

	// Try putting another value with same key.
	things.PutNX(key, []byte("beta"))

	// Read value back in a different read-only transaction.
	got, _ = things.Get(key)

	fmt.Printf("The value of %q in `%s` is still %q\n", key, bucket, got)

	// Output:
	// The value of "A" in `things` is "alpha"
	// The value of "A" in `things` is still "alpha"
}
// Show we don't overwrite existing values when using PutNX.
Show we don't overwrite existing values when using PutNX.
// Show we don ' t overwrite existing values when using PutNX .
func ExampleBucket_PutNX() {
	bx, _ := buckets.Open(tempfile())
	defer os.Remove(bx.Path())
	defer bx.Close()
	bucket := []byte("things")
	things, _ := bx.New(bucket)
	key, value := []byte("A"), []byte("alpha")
	if err := things.Put(key, value); err != nil {
		fmt.Printf("could not insert item: %v", err)
	}
	got, _ := things.Get(key)
	fmt.Printf("The value of %q in `%s` is %q\n", key, bucket, got)
	things.PutNX(key, []byte("beta"))
	got, _ = things.Get(key)
	fmt.Printf("The value of %q in `%s` is still %q\n", key, bucket, got)
}
func ExampleBucket_PutNX ( ) { bx , _ := buckets . Open ( tempfile ( ) ) defer os . Remove ( bx . Path ( ) ) defer bx . Close ( ) bucket := [ ] byte ( " " ) things , _ := bx . New ( bucket ) key , value := [ ] byte ( " " ) , [ ] byte ( " " ) if err := things . Put ( key , value ) ; err != nil { fmt . Printf ( " " , err ) } got , _ := things . Get ( key ) fmt . Printf ( " \n " , key , bucket , got ) things . PutNX ( key , [ ] byte ( " " ) ) got , _ = things . Get ( key ) fmt . Printf ( " \n " , key , bucket , got ) }
Show we don't overwrite existing values when using PutNX.
Show we don ' t overwrite existing values when using PutNX .
// Create a new `things` bucket. // Put key/value into the `things` bucket. // Read value back in a different read-only transaction. // Try putting another value with same key. // Read value back in a different read-only transaction. // Output: // The value of "A" in `things` is "alpha" // The value of "A" in `things` is still "alpha"