Skip to main content


Memcached is a general-purpose distributed memory-caching system. This plugin provide a bridge for Memcached databases.


In this example, we will setup the plugin to be used in the SMTP SMTP Receiver service. First, create a connection pool to the Memcached database.

// /etc/vsmtp/smtp-receiver/services/db.rhai
// Import the plugin stored in the `plugins` directory.
import "plugins/libmemcached_plugin" as cache;

export const cache = cache::connect(#{
// Connect to a server on the port 11211 with a timeout.
url: "memcache://localhost:11211",
timeout: "10s",
// Number of connections to open in the pool.
connections: 4,

Then query the database in your rules.

import "services/db" as db;

fn on_connect(ctx) {[
action "get value from my memcached server" || {
// For the sake of this example, we assume that there is a "client_ip" as a key and "" as its value.
const client_ip = db::cache.get("client_ip");
log("info", `ip of my client is: ${client_ip}`);