perfect.org
Documentation
|
API Documentation
PerfectLib
Perfect-CouchDB
Perfect-CURL
Perfect-Filemaker
Perfect-GoogleAnalytics-MeasurementProtocol
Perfect-HTTP
Perfect-HTTPServer
Perfect-Logger
Perfect-MongoDB
Perfect-Mustache
Perfect-MySQL
Perfect-MariaDB
Perfect-Net
Perfect-Notifications
Perfect-PostgreSQL
Perfect-Redis
Perfect-RequestLogger
Perfect-Session
Perfect-Session-SQLite
Perfect-Session-CouchDB
Perfect-Session-MySQL
Perfect-Session-PostgreSQL
Perfect-SQLite
Perfect-Thread
Perfect-WebSockets
Perfect-XML
Perfect-Zip
Turnstile-Perfect
Perfect-Turnstile-CouchDB
Perfect-Turnstile-MySQL
Perfect-Turnstile-PostgreSQL
Perfect-Turnstile-SQLite
StORM
CouchDB-StORM
MySQL-StORM
Postgres-StORM
SQLite-StORM
Module: Perfect-Redis
global var
redisDefaultPort = 6379
enum
RedisResponse
case
error(type: String, msg: String)
case
simpleString(String)
case
bulkString([UInt8]?)
case
integer(Int)
case
array([RedisResponse])
var
isSimpleOK: Bool
Returns true if the response is the Redis standard +OK
func
toString() -> String?
struct
RedisClientIdentifier
func
init()
func
init(withHost: String, port: Int, password: String = "", netGenerator: @escaping () -> NetTCP = { return NetTCP() })
class
RedisClient
enum
RedisValue
case
string(String)
case
binary([UInt8])
static func
func getClient(withIdentifier: RedisClientIdentifier, callback: @escaping (() throws -> RedisClient) -> ())
static func
func releaseClient(_ client: RedisClient)
extension
RedisClient
func
auth(withPassword: String, callback: @escaping redisResponseCallback)
Authorize with password
func
ping(callback: @escaping redisResponseCallback)
Ping the server
extension
RedisClient
func
flushAll(callback: @escaping redisResponseCallback)
Flush all keys.
func
save(callback: @escaping redisResponseCallback)
Save the database sync.
func
backgroundSave(callback: @escaping redisResponseCallback)
Save the database async.
func
lastSave(callback: @escaping redisResponseCallback)
Timestamp of the last save.
func
rewriteAppendOnlyFile(callback: @escaping redisResponseCallback)
Timestamp of the last save.
func
dbSize(callback: @escaping redisResponseCallback)
Number of keys in the database.
func
keys(pattern: String, callback: @escaping redisResponseCallback)
Returns the keys matching pattern.
func
randomKey(callback: @escaping redisResponseCallback)
Returns a random key from the database.
func
select(index: Int, callback: @escaping redisResponseCallback)
Select the database at index.
extension
RedisClient
enum
KillFilter
Indicates the type of clients to kill.
case
addr(ip: String, port: Int)
case
id(String)
case
typeNormal, typeMaster, typeSlave, typePubSub
case
typeNormal, typeMaster, typeSlave, typePubSub
case
typeNormal, typeMaster, typeSlave, typePubSub
case
typeNormal, typeMaster, typeSlave, typePubSub
enum
ReplyType
Client reply setting.
case
on, off, skip
case
on, off, skip
case
on, off, skip
func
clientList(callback: @escaping redisResponseCallback)
List connected clients.
func
clientGetName(callback: @escaping redisResponseCallback)
Get the name of the connected client.
func
clientSetName(to: String, callback: @escaping redisResponseCallback)
Set the name of the connected client.
func
clientKill(filters: [KillFilter], skipMe: Bool = true, callback: @escaping redisResponseCallback)
Kill the indicated client connection(s).
func
clientPause(timeoutSeconds: Double, callback: @escaping redisResponseCallback)
Pause all client activity for the indicated timeout.
func
clientReply(type: ReplyType, callback: @escaping redisResponseCallback)
Adjust client replies.
extension
RedisClient
func
set(key: String, value: RedisValue, expires: Double = 0.0, ifNotExists: Bool = false, ifExists: Bool = false, callback: @escaping redisResponseCallback)
Set the key to the String value with an optional expiration.
func
set(keysValues: [(String, RedisValue)], callback: @escaping redisResponseCallback)
Set the keys/values.
func
setIfNonExists(keysValues: [(String, RedisValue)], callback: @escaping redisResponseCallback)
Set the keys/values.
func
get(key: String, callback: @escaping redisResponseCallback)
Get the key value.
func
get(keys: [String], callback: @escaping redisResponseCallback)
Get the keys values.
func
getSet(key: String, newValue: RedisValue, callback: @escaping redisResponseCallback)
Get the key value and set to new value.
func
delete(keys: String..., callback: @escaping redisResponseCallback)
Get the key value.
func
increment(key: String, callback: @escaping redisResponseCallback)
Increment the key value.
func
increment(key: String, by: Int, callback: @escaping redisResponseCallback)
Increment the key value.
func
increment(key: String, by: Double, callback: @escaping redisResponseCallback)
Increment the key value.
func
decrement(key: String, callback: @escaping redisResponseCallback)
Decrement the key value.
func
decrement(key: String, by: Int, callback: @escaping redisResponseCallback)
Increment the key value.
func
rename(key: String, newKey: String, callback: @escaping redisResponseCallback)
Rename a key.
func
renameIfnotExists(key: String, newKey: String, callback: @escaping redisResponseCallback)
Rename a key if new name does not exist.
func
exists(keys: String..., callback: @escaping redisResponseCallback)
Check if the indicated keys exist.
func
append(key: String, value: RedisValue, callback: @escaping redisResponseCallback)
Append a value to the key.
func
expire(key: String, seconds: Double, callback: @escaping redisResponseCallback)
Set the expiration for the indicated key.
func
expireAt(key: String, seconds: Double, callback: @escaping redisResponseCallback)
Set the expiration for the indicated key.
func
timeToExpire(key: String, callback: @escaping redisResponseCallback)
Returns the expiration in milliseconds for the indicated key.
func
persist(key: String, callback: @escaping redisResponseCallback)
Remove the expiration for the indicated key.
extension
RedisClient
enum
IntegerType
BITFIELD operation integer types.
case
signed(Int)
case
unsigned(Int)
enum
SubCommand
BITFIELD operation commands.
case
get(type: IntegerType, offset: Int)
case
set(type: IntegerType, offset: Int, value: Int)
case
setMul(type: IntegerType, offset: String, value: Int)
case
incrby(type: IntegerType, offset: Int, increment: Int)
case
overflowWrap
case
overflowSat
case
overflowFail
enum
BitOperation
BITOP bit operations.
case
and, or, xor, not
case
and, or, xor, not
case
and, or, xor, not
case
and, or, xor, not
func
bitCount(key: String, callback: @escaping redisResponseCallback)
Count the set bits in a value.
func
bitCount(key: String, start: Int, end: Int, callback: @escaping redisResponseCallback)
Count the set bits in a value.
func
bitField(key: String, commands: [SubCommand], callback: @escaping redisResponseCallback)
Perform a bitfield operation on a value
func
bitOp(_ op: BitOperation, destKey: String, srcKeys: String..., callback: @escaping redisResponseCallback)
Perform a bitfield operation on a value.
func
bitPos(key: String, position: Int, callback: @escaping redisResponseCallback)
Perform a bitpos operation.
func
bitPos(key: String, position: Int, start: Int, callback: @escaping redisResponseCallback)
Perform a bitpos operation on a range.
func
bitPos(key: String, position: Int, start: Int, end: Int, callback: @escaping redisResponseCallback)
Perform a bitpos operation on a range.
func
bitGet(key: String, offset: Int, callback: @escaping redisResponseCallback)
Get the bit at the indicated offset.
func
bitSet(key: String, offset: Int, value: Bool, callback: @escaping redisResponseCallback)
Set the bit at the indicated offset.
extension
RedisClient
func
listPrepend(key: String, values: [RedisValue], callback: @escaping redisResponseCallback)
Push values to the beginning of the list
func
listAppend(key: String, values: [RedisValue], callback: @escaping redisResponseCallback)
Push values to the end of the list
func
listPrependX(key: String, value: RedisValue, callback: @escaping redisResponseCallback)
Push value to the beginning of the list. LPUSHX
func
listAppendX(key: String, value: RedisValue, callback: @escaping redisResponseCallback)
Push value to the end of the list. RPUSHX
func
listPopFirst(key: String, callback: @escaping redisResponseCallback)
Pop and return the first element from the list
func
listPopLast(key: String, callback: @escaping redisResponseCallback)
Pop and return the last element from the list
func
listPopFirstAppend(key: String, callback: @escaping redisResponseCallback)
Pop and return the first element from the list
func
listPopLastAppend(sourceKey: String, destKey: String, callback: @escaping redisResponseCallback)
Pop and return the last element from the list. Append the element to the destination list.
func
listPopLastAppendBlocking(sourceKey: String, destKey: String, callback: @escaping redisResponseCallback)
Pop and return the last element from the list. Append the element to the destination list.
func
listPopFirstBlocking(keys: String..., timeout: Int, callback: @escaping redisResponseCallback)
Pop and return the first element from the list
func
listPopLastBlocking(keys: String..., timeout: Int, callback: @escaping redisResponseCallback)
Pop and return the last element from the list
func
listLength(key: String, callback: @escaping redisResponseCallback)
The length of the list
func
listTrim(key: String, start: Int, stop: Int, callback: @escaping redisResponseCallback)
Remove the items in the range
func
listRange(key: String, start: Int, stop: Int, callback: @escaping redisResponseCallback)
Returns the list items in the indicated range
func
listGetElement(key: String, index: Int, callback: @escaping redisResponseCallback)
Returns the list item at the indicated offset.
func
listInsert(key: String, element: RedisValue, before: RedisValue, callback: @escaping redisResponseCallback)
Inserts the new item before the indicated value.
func
listInsert(key: String, element: RedisValue, after: RedisValue, callback: @escaping redisResponseCallback)
Inserts the new item after the indicated value.
func
listSet(key: String, index: Int, value: RedisValue, callback: @escaping redisResponseCallback)
Set the item at index to value.
func
listRemoveMatching(key: String, value: RedisValue, count: Int, callback: @escaping redisResponseCallback)
Remove the first N elements matching value.
extension
RedisClient
func
multiBegin(callback: @escaping redisResponseCallback)
Begin a transaction.
func
multiExec(callback: @escaping redisResponseCallback)
Execute a transation.
func
multiDiscard(callback: @escaping redisResponseCallback)
Discard a transaction.
func
multiWatch(keys: [String], callback: @escaping redisResponseCallback)
Watch keys for modification during a transaction.
func
multiUnwatch(callback: @escaping redisResponseCallback)
Unwatch keys for modification during a transaction.
extension
RedisClient
func
subscribe(patterns: [String], callback: @escaping redisResponseCallback)
Subscribe to the following patterns.
func
subscribe(channels: [String], callback: @escaping redisResponseCallback)
Subscribe to the following channels.
func
unsubscribe(patterns: [String], callback: @escaping redisResponseCallback)
Unsubscribe to the following patterns.
func
unsubscribe(channels: [String], callback: @escaping redisResponseCallback)
Unsubscribe to the following channels.
func
publish(channel: String, message: RedisValue, callback: @escaping redisResponseCallback)
Publish a message to the channel.
func
readPublished(timeoutSeconds: Double, callback: @escaping redisResponseCallback)
Read a published message given a timeout.
extension
RedisClient
func
setAdd(key: String, elements: [RedisValue], callback: @escaping redisResponseCallback)
Inserts the new elements into the set.
func
setCount(key: String, callback: @escaping redisResponseCallback)
Returns the number of elements in the set.
func
setDifference(key: String, againstKeys: [String], callback: @escaping redisResponseCallback)
Returns the difference between `key` and `againstKeys`.
func
setStoreDifference(into: String, ofKey: String, againstKeys: [String], callback: @escaping redisResponseCallback)
Stores to `into` the difference between `ofKey` and `againstKeys`.
func
setIntersection(key: String, againstKeys: [String], callback: @escaping redisResponseCallback)
Returns the intersection of `key` and `againstKeys`.
func
setStoreIntersection(into: String, ofKey: String, againstKeys: [String], callback: @escaping redisResponseCallback)
Stores to `into` the intersection of `ofKey` and `againstKeys`.
func
setUnion(key: String, againstKeys: [String], callback: @escaping redisResponseCallback)
Returns the union of `key` and `againstKeys`.
func
setStoreUnion(into: String, ofKey: String, againstKeys: [String], callback: @escaping redisResponseCallback)
Stores to `into` the union of `ofKey` and `againstKeys`.
func
setContains(key: String, value: RedisValue, callback: @escaping redisResponseCallback)
Checks if the set `key` contains `value`.
func
setMembers(key: String, callback: @escaping redisResponseCallback)
Returns the members of set `key`.
func
setMove(fromKey: String, toKey: String, value: RedisValue, callback: @escaping redisResponseCallback)
Moves the set `value` `fromKey` to `toKey`.
func
setRandomPop(key: String, count: Int, callback: @escaping redisResponseCallback)
Removes and returns `count` random elements of set `key`.
func
setRandomPop(key: String, callback: @escaping redisResponseCallback)
Removes and returns a random element of set `key`.
func
setRandomGet(key: String, count: Int, callback: @escaping redisResponseCallback)
Returns `count` random elements of set `key`.
func
setRandomGet(key: String, callback: @escaping redisResponseCallback)
Returns a random element of set `key`.
func
setRemove(key: String, value: RedisValue, callback: @escaping redisResponseCallback)
Removes the value from set `key`.
func
setRemove(key: String, values: [RedisValue], callback: @escaping redisResponseCallback)
Removes the values from set `key`.
func
setScan(key: String, cursor: Int = 0, pattern: String? = nil, count: Int? = nil, callback: @escaping redisResponseCallback)
Scans the set `key` given the current cursor, which should start from zero.
Optionally accepts a pattern and a maximum returned value count.