Skip to content

Commit

Permalink
builtin routelib
Browse files Browse the repository at this point in the history
  • Loading branch information
dormando committed Dec 5, 2024
1 parent 4e0604d commit 3bb24c1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
7 changes: 5 additions & 2 deletions content/features/proxy/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ To download and compile Memcached with its proxy features enabled, follow these
- proxy_arg: string to pass to lua library
```
1. Download the route library:
1. [Optionally] Download the route library:

Memcached ships with `routelib` built in. If you want to modify this base
library or use a newer version than what was provided with memcached you may download it yourself.

```console
wget https://raw.githubusercontent.com/memcached/memcached-proxylibs/main/lib/routelib/routelib.lua
```

1. Move the `routelib.lua` file that you downloaded in the previous step to some permanent place on your file system, and take note of it. You will need to refer to its path when you run the Memcached proxy.
1. [Optionally] Move the `routelib.lua` file that you downloaded in the previous step to some permanent place on your file system, and take note of it. You will need to refer to its path when you run the Memcached proxy.
12 changes: 2 additions & 10 deletions content/features/proxy/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ Because the Memcached built-in proxy is a non-default, compile-time configuratio
Note: For the sake of simplicity and easier cleanup, this quick-start guide doesn't include a `make install` step. If you want to install the proxy-enabled Memcached on this machine, then you can do as a final step at the end of this guide.
## Download the route library
Run the following command:
```
wget https://raw.githubusercontent.com/memcached/memcached-proxylibs/main/lib/routelib/routelib.lua
```
## Configure the proxy
To create a minimal proxy configuration file named `config.lua`, run the following command:
Expand Down Expand Up @@ -113,10 +105,10 @@ routes{
./memcached -l localhost -p 11213 &
```
1. Launch a third Memcached server in proxy mode, by specifying the proxy-specific configuration files that you downloaded and created, respectively, in previous steps:
1. Launch a third Memcached server in proxy mode, by specifying the proxy-specific configuration file that you created, in previous steps:
```
./memcached -l localhost -p 11211 -o proxy_config=routelib.lua,proxy_arg=config.lua &
./memcached -l localhost -p 11211 -o proxy_config=routelib,proxy_arg=config.lua &
```
## Connect to and use the proxy
Expand Down
7 changes: 5 additions & 2 deletions content/features/proxy/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ To run the proxy in the background, append a `&` to the end of the command, in t

The following example command launches a Memcached proxy with the following aspects:

* The proxy loads a route library file named `routelib.lua` stored in your home directory. For more information about obtaining this file, see [Download and build the proxy]({{<proxy_base_path>}}install#download).
* The proxy loads a route library file named `routelib` that it ships with. For more information about updating or modifying this file, see [Download and build the proxy]({{<proxy_base_path>}}install#download).
* The proxy loads a configuration file named `my_config.lua` stored in your home directory.
* The proxy listens for connections on TCP port `11212`.
* The proxy runs in the background.

```console
# Using the builtin routelib
memcached -o proxy_config=routelib,proxy_arg=$HOME/my_config.lua -p 11212 &
# Manually using a modified or newer routelib
memcached -o proxy_config=$HOME/routelib.lua,proxy_arg=$HOME/my_config.lua -p 11212 &
```

Expand Down Expand Up @@ -88,7 +91,7 @@ To specify multiple, tagged TCP ports, include the `-l` or `--listen` command-li
For example, the following command runs the proxy with three TCP ports active. Two of the ports are tagged `main` and `alt`, respectively, and one port has no tag associated with it:

```console
memcached -o proxy_config=$HOME/routelib.lua,proxy_arg=$HOME/my_config.lua -l 127.0.0.1:11211 -l main:127.0.0.1:11212 -l alt:127.0.0.1:11213 &
memcached -o proxy_config=routelib,proxy_arg=$HOME/my_config.lua -l 127.0.0.1:11211 -l main:127.0.0.1:11212 -l alt:127.0.0.1:11213 &
```

For more information on configuring the proxy to handle requests based on connected ports, see [Define multiple route trees]({{<proxy_base_path>}}configure/#multiple-trees).
Expand Down

0 comments on commit 3bb24c1

Please sign in to comment.