We've been hoping that mkdocs-material will ship the much anticipated search enhancements for some time, but it's time to recognize that we need to do something to improve the search results with how things work right now. This is a big commit that changes the titles of the various pages from the code-annotated synopsis to just the name of the function. This makes it much easier now to match things like `kumo.reject` directly, but `reject` remains awkward to find. I think this is the best that we can do at this time. A few functions have been annotated with the `status: deprecated` to show as deprecated in the toc/nav (shows with a little trash can next to the name).
3.1 KiB
redis.open
redis.open { PARAMS }
Opens a connection to a Redis data store and returns a connection handle.
local redis = require 'redis'
-- Open a connection and increment a counter, returning its new value.
-- Redis URL syntax is: 'redis://[<username>][:<password>@]<hostname>[:port][/[<db>][?protocol=<protocol>]]'
local conn = redis.open { node = 'redis://127.0.0.1/' }
print(conn:query('incr', 'test-count'))
PARAMS is a lua table with the following keys:
-
node- the redis URL string identifying the server. Can be a table listing multiple servers if you have a redis cluster deployed. Redis URL strings have the formredis://[<username>][:<password>@]<hostname>[:port][/[<db>][?protocol=<protocol>]] -
pool_size- optional integer. Specifies the maximum number of spare connections to be maintained by the connection pool. The default is 10. -
read_from_replicas- optional boolean. If true, when connecting to a redis cluster, reads are issued to replicas while writes are issued to the primary data stores. -
username- optional string. convenience for working with the cluster, so that you only need to specify the username once. This is not used for connecting to a single node. -
password- optional string. convenience for working with the cluster, so that you only need to specify the password once. This is not used for connecting to a single node. -
connect_timeout- optional duration string. Specify how long to keep attempting to connect to redis. The default is30 seconds. {{since('2024.06.10-84e84b89', inline=True)}} -
wait_timeout- optional duration string. Specify how long to wait for an available connection. If the pool is at capacity (pool_size), then anopencall will block for up this duration for a connection to be released and made to connect to redis. The default is30 seconds. {{since('2024.09.02-c5476b89', inline=True)}} -
response_timeout- optional duration string. Specify how long to wait for the response to a query. {{since('2024.09.02-c5476b89', inline=True)}} -
recycle_timeout- optional duration string. Specify how long to wait for the liveness check when testing whether a connection can be resused. {{since('2024.09.02-c5476b89', inline=True)}} -
cluster- optional boolean. Set this to true to explicit use a cluster-enabled client. The default is false if the number of nodes is one, or true if the number of nodes is greater than one. You generally don't need to set this, but can do so to force a cluster connection when you have only a single node address. {{since('2024.09.02-c5476b89', inline=True)}}
The returned connection handle has a single "query" method:
conn:query(CMD, [ARGS])
Issue a redis command and return the result.
See Redis Commands for a list of commands.
The redis INCRBY command increments a key by a value; it has the syntax:
INCRBY key increment
To use INCRBY to increment my-key by 2:
conn:query("INCRBY", "my-key", 2)