-
Notifications
You must be signed in to change notification settings - Fork 451
Server Configuration
Users of the Dalli client need to specify a configuration of servers as the first argument when initializing a Dalli::Client
object. This argument defines the set of memcached servers that the client will connect to, along with some optional weighting and authentication parameters.
This argument can take one of three forms:
- an array of strings
nil
- a string
In the last case, where a string is passed, it is simply wrapped in an Array and processing continues as if an array containing the single string was passed to the Dalli client.
Note that while the servers configuration argument is required, it can take a nil
value - indicating the default should be used.
When the argument is nil
, Dalli first checks the value of the MEMCACHE_SERVERS
environment variable. If the environment variable is set, then the client behaves as if that string value was passed as the configuration argument.
If the MEMCACHE_SERVERS
environment variable is not set, then the client behaves as if the initial configuration argument was the string array ['127.0.0.1:11211']
To generate the final configuration Dalli iterates through each entry in the argument array. Each array entry is parsed as a CSV
string, split into multiple entries in the output array as appropriate. Any empty values are eliminated from the output array.
As a concrete example, consider the two entry argument
['abc.example.com', 'def.example.net:12345:4,198.51.100.31:11211,[2001:db8:ffff:ffff:ffff:ffff:ffff:ffff]:11222,']
This would be parsed into the four entry output
['abc.example.com', 'def.example.net:12345:4', '198.51.100.31:11211', '[2001:db8:ffff:ffff:ffff:ffff:ffff:ffff]:11222']
Each of the entries in the output are then processed as individual server configurations
Configuration for an individual server can take one of three forms:
- A colon separated string of (host or IP, port, weight) where both port and weight are optional. IPv6 values must be enclosed in square brackets.
- Examples:
'localhost'
'127.0.0.1:12345'
'abc.example.org:22222:3'
- Examples:
- A colon separated string of (UNIX socket, weight) where the weight is optional. This form is not supported on Windows.
- Examples:
'/var/run/memcached/socket'
'/tmp/xyz:3'
- Examples:
- A URI with a 'memcached' protocol, which will typically include a username/password
- Examples:
'memcached://127.0.0.1?username=testuser&password=testpass'
'memcached://def.example.com:12345?username=testadmin&password=pass'
- Examples:
-
General Information
- Requirements and Integrations
- Installing memcached
-
Getting Started
- Using Dalli with SSL/TLS
- Setting up a Development Environment
- Configuring the Dalli Client
- Operational Considerations