| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- // Copyright 2012 Gary Burd
- //
- // Licensed under the Apache License, Version 2.0 (the "License"): you may
- // not use this file except in compliance with the License. You may obtain
- // a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- // License for the specific language governing permissions and limitations
- // under the License.
- package redis_test
- import (
- "fmt"
- "github.com/garyburd/redigo/redis"
- )
- func ExampleBool() {
- c, err := dial()
- if err != nil {
- panic(err)
- }
- defer c.Close()
- c.Do("SET", "foo", 1)
- exists, _ := redis.Bool(c.Do("EXISTS", "foo"))
- fmt.Printf("%#v\n", exists)
- // Output:
- // true
- }
- func ExampleInt() {
- c, err := dial()
- if err != nil {
- panic(err)
- }
- defer c.Close()
- c.Do("SET", "k1", 1)
- n, _ := redis.Int(c.Do("GET", "k1"))
- fmt.Printf("%#v\n", n)
- n, _ = redis.Int(c.Do("INCR", "k1"))
- fmt.Printf("%#v\n", n)
- // Output:
- // 1
- // 2
- }
- func ExampleString() {
- c, err := dial()
- if err != nil {
- panic(err)
- }
- defer c.Close()
- c.Do("SET", "hello", "world")
- s, err := redis.String(c.Do("GET", "hello"))
- fmt.Printf("%#v\n", s)
- // Output:
- // "world"
- }
|