Module resty.session.memcached
Memcached backend for session library
Configuration
configuration | Distributed shared memory storage backend configuration |
Constructors
module.new ([configuration]) | Create a memcached storage. |
Storage
instance:set (name, key, value, ttl, current_time[, old_key], stale_ttl[, metadata], remember) | Store session data. |
instance:get (name, key) | Retrieve session data. |
instance:delete (name, key[, metadata]) | Delete session data. |
instance:read_metadata (name, audience, subject, current_time) | Read session metadata. |
Configuration
- configuration
-
Distributed shared memory storage backend configuration
Fields:
- prefix Prefix for the keys stored in memcached.
- suffix Suffix for the keys stored in memcached.
- host
The host to connect (defaults to
"127.0.0.1"
). - port
The port to connect (defaults to
11211
). - socket
The socket file to connect to (defaults to
nil
). - connect_timeout
Controls the default timeout value used in TCP/unix-domain socket object’s
connect
method. - send_timeout
Controls the default timeout value used in TCP/unix-domain socket object’s
send
method. - read_timeout
Controls the default timeout value used in TCP/unix-domain socket object’s
receive
method. - keepalive_timeout Controls the default maximal idle time of the connections in the connection pool.
- pool A custom name for the connection pool being used.
- pool_size The size of the connection pool.
- backlog A queue size to use when the connection pool is full (configured with @pool_size).
- ssl
Enable SSL (defaults to
false
). - ssl_verify
Verify server certificate (defaults to
nil
). - server_name The server name for the new TLS extension Server Name Indication (SNI).
Constructors
- module.new ([configuration])
-
Create a memcached storage.
This creates a new memcached storage instance.
Parameters:
- configuration table memcached storage configuration (optional)
Returns:
-
table
memcached storage instance
Storage
- instance:set (name, key, value, ttl, current_time[, old_key], stale_ttl[, metadata], remember)
-
Store session data.
Parameters:
- name string cookie name
- key string session key
- value string session value
- ttl number session ttl
- current_time number current time
- old_key string old session id (optional)
- stale_ttl string stale ttl
- metadata table table of metadata (optional)
- remember boolean whether storing persistent session or not
Returns:
- true or nil ok
- string error message
- instance:get (name, key)
-
Retrieve session data.
Parameters:
Returns:
- instance:delete (name, key[, metadata])
-
Delete session data.
Parameters:
Returns:
- boolean or nil session data
- string error message
- instance:read_metadata (name, audience, subject, current_time)
-
Read session metadata.
Parameters:
- name string cookie name
- audience string session key
- subject string session key
- current_time number current time
Returns: