Documentation ¶
Index ¶
- Variables
- func BgSave(fileName string, complete chan bool) string
- func Decr(key string) string
- func Del(key ...string) (deletedCount int)
- func Exists(key string) int
- func Get(key string) string
- func HDel(key, field string) (existed int)
- func HExists(key, field string) (existed int)
- func HGet(key, field string) string
- func HSet(key, field, value string) (existed int)
- func Hkeys(key string) []string
- func Hvals(key string) []string
- func Incr(key string) string
- func InitDB(fileName string)
- func Keys(pattern string) (out []string)
- func Llen(key string) int
- func Psubscribe(pattern ...string) consumer
- func Rpush(key string, value ...string) int
- func Sadd(key string, member ...string) (additions int)
- func Scard(key string) (count int)
- func Set(key, value string) string
- func Setnx(key, value string) int
- func Smembers(key string) (out []string)
- func Type(key string) string
- type Hash
- func (h Hash) Copy() Hash
- func (h Hash) Delete(key string)
- func (h Hash) Exists(key string) bool
- func (h Hash) Get(key string) string
- func (h Hash) GetExists(key string) (string, bool)
- func (h Hash) Keys() []string
- func (h Hash) Set(key, value string)
- func (h Hash) Size() int
- func (h Hash) ToMap() map[string]string
- func (h Hash) Valid() bool
- func (h Hash) Values() []string
- type List
- type RedisSet
Constants ¶
This section is empty.
Variables ¶
var (
DefaultDumpFileName = "../redisServer.dump.json"
)
Functions ¶
func BgSave ¶
Save the DB in background. The OK code is immediately returned. Redis forks, the parent continues to serve the clients, the child saves the DB on disk then exits. A client my be able to check if the operation succeeded using the LASTSAVE command. Please refer to the persistence documentation for detailed information.
Return value Simple string reply
func Decr ¶
Decrements the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer. This operation is limited to 64 bit signed integers. See INCR for extra information on increment/decrement operations.
Return value String reply: the value of key after the decrement
func Del ¶
Removes the specified keys. A key is ignored if it does not exist.
Return value Integer reply: The number of keys that were removed.
func Exists ¶
Returns if key exists.
Return value Integer reply, specifically: 1 if the key exists. 0 if the key does not exist.
func Get ¶
Get the value of key. If the key does not exist the special value nil is returned. An error is returned if the value stored at key is not a string, because GET only handles string values.
Return value Bulk string reply: the value of key, or nil when key does not exist.
func HDel ¶
Removes the specified fields from the hash stored at key. Specified fields that do not exist within this hash are ignored. If key does not exist, it is treated as an empty hash and this command returns 0.
Return value Integer reply: the number of fields that were removed from the hash, not including specified but non existing fields.
func HExists ¶
Returns if field is an existing field in the hash stored at key.
Return value Integer reply, specifically: 1 if the hash contains field. 0 if the hash does not contain field, or key does not exist.
func HGet ¶
Returns the value associated with field in the hash stored at key.
Return value Bulk string reply: the value associated with field, or nil when field is not present in the hash or key does not exist.
func HSet ¶
Sets field in the hash stored at key to value. If key does not exist, a new key holding a hash is created. If field already exists in the hash, it is overwritten.
Return value Integer reply, specifically: 1 if field is a new field in the hash and value was set. 0 if field already exists in the hash and the value was updated.
func Hkeys ¶
Returns all field names in the hash stored at key.
Return value Array reply: list of fields in the hash, or an empty list when key does not exist.
func Hvals ¶
Returns all values in the hash stored at key.
Return value Slice reply: list of values in the hash, or an empty list when key does not exist.
func Incr ¶
Increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer.
Return value String reply: the value of key after the increment
func Keys ¶
Returns all keys matching pattern.
While the time complexity for this operation is O(N), the constant times are fairly low. For example, Redis running on an entry level laptop can scan a 1 million key database in 40 milliseconds. Warning: consider KEYS as a command that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don't use KEYS in your regular application code. If you're looking for a way to find keys in a subset of your keyspace, consider using sets. Supported glob-style patterns: h?llo matches hello, hallo and hxllo h*llo matches hllo and heeeello h[ae]llo matches hello and hallo, but not hillo Use \ to escape special characters if you want to match them verbatim.
Return value Array reply: list of keys matching pattern.
func Llen ¶
Returns the length of the list stored at key. If key does not exist, it is interpreted as an empty list and 0 is returned. An error is returned when the value stored at key is not a list.
Return value Integer reply: the length of the list at key.
func Psubscribe ¶
func Psubscribe(pattern ...string) consumer
Subscribes the client to the given patterns. Supported glob-style patterns: h?llo subscribes to hello, hallo and hxllo h*llo subscribes to hllo and heeeello h[ae]llo subscribes to hello and hallo, but not hillo Use \ to escape special characters if you want to match them verbatim.
func Sadd ¶
Add the specified members to the set stored at key. Specified members that are already a member of this set are ignored. If key does not exist, a new set is created before adding the specified members. An error is returned when the value stored at key is not a set.
Return value Integer reply: the number of elements that were added to the set, not including all the elements already present into the set.
func Scard ¶
Returns all the members of the set value stored at key. This has the same effect as running SINTER with one argument key.
Return value Array reply: all elements of the set.
func Set ¶
Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation.
func Setnx ¶
Set key to hold string value if key does not exist. In that case, it is equal to SET. When key already holds a value, no operation is performed. SETNX is short for "SET if N ot e X ists".
Return value Integer reply, specifically: 1 if the key was set 0 if the key was not set
Types ¶
type Hash ¶
type Hash struct {
// contains filtered or unexported fields
}
Hash is a concurrent safe string map
func Hgetall ¶
Returns all fields and values of the hash stored at key. In the returned value, every field name is followed by its value, so the length of the reply is twice the size of the hash.
Return value map[string]string reply: list of fields and their values stored in the hash, or an empty list when key does not exist.