MEMCACHE_TABLE(5)

πŸ’– MEMCACHE_TABLE(5) πŸ’–

okay bestie, so this is the File Formats Manual page for memcache_table β€” it's literally called Postfix memcache client configuration and it's about to be your new obsession. no cap. πŸ¦‹


✨ NAME ✨

memcache_table β€” Postfix memcache client configuration, and yes that's the whole vibe πŸ’…


✨ SYNOPSIS ✨

postmap -q "string" memcache:/etc/postfix/filename

postmap -q - memcache:/etc/postfix/filename <inputfile

✨ DESCRIPTION ✨

so the Postfix mail system uses optional tables for address rewriting or mail routing, right? normally those tables live in lmdb:, cdb:, hash:, or dbm: format. classic. 🌸

but plot twist: lookup tables can also be specified as memcache instances. to use memcache lookups you define a memcache source as a lookup table in main.cf, like:

virtual_alias_maps = memcache:/etc/postfix/memcache-aliases.cf

and the file /etc/postfix/memcache-aliases.cf has the same format as the Postfix main.cf file, and it specifies the parameters described below. it's giving config-inception 😭

the Postfix memcache client supports the lookup, update, delete and sequence (first/next) operations. heads up though β€” the sequence operation requires a backup database that supports the operation. no backup, no sequence, periodt.


πŸ‘‘ MEMCACHE MAIN PARAMETERS πŸ‘‘

πŸ’– memcache (default: inet:localhost:11211)

the memcache server (note: singular πŸ‘€) that Postfix will try to connect to.

  • for a TCP server specify inet: followed by a hostname or address, :, and a port name or number.
  • specify an IPv6 address inside [].
  • for a UNIX-domain server specify unix: followed by the socket pathname.

examples, slay:

memcache = inet:memcache.example.com:11211
memcache = inet:127.0.0.1:11211
memcache = inet:[fc00:8d00:189::3]:11211
memcache = unix:/path/to/socket
NOTE: to access a UNIX-domain socket with the proxymap(8) server, the socket must be accessible by the unprivileged postfix user. don't forget, bestie 🫢

πŸ’– backup (default: undefined)

an optional Postfix database that provides persistent backup for the memcache database. the Postfix memcache client will update the memcache database whenever it looks up or changes information in the persistent database. specify a Postfix "type:table" database. examples:

# Non-shared postscreen cache.
backup = btree:/var/lib/postfix/postscreen_cache_map

# Shared postscreen cache for processes on the same host.
backup = proxy:btree:/var/lib/postfix/postscreen_cache_map

access to remote proxymap servers is under development β€” so like, coming soon, not yet, don't come for me πŸ”₯

NOTE 1: when sharing a persistent postscreen(8) or verify(8) cache, disable automatic cache cleanup (set *_cache_cleanup_interval = 0) except with one Postfix instance that will be responsible for cache cleanup.
NOTE 2: when multiple tables share the same memcache database, each table should use the key_format feature (see below) to prepend its own unique string to the lookup key. otherwise, automatic postscreen(8) or verify(8) cache cleanup may not work. one job each, okay? πŸ’€
NOTE 3: when the backup database is accessed with "proxy:" lookups, the full backup database name (including the "proxy:" prefix) must be specified in the proxymap server's proxy_read_maps or proxy_write_maps setting (depending on whether the access is read-only or read-write).

πŸ’– flags (default: 0)

optional flags that should be stored along with a memcache update. the flags are ignored when looking up information. they're just there for the aesthetic ✨

πŸ’– ttl (default: 3600)

the expiration time in seconds of memcache updates. tick tock ⏳

NOTE 1: when using a memcache table as postscreen(8) or verify(8) cache without persistent backup, specify a zero *_cache_cleanup_interval value with all Postfix instances that use the memcache, and specify the largest postscreen(8) *_ttl value or verify(8) *_expire_time value as the memcache table's ttl value.
NOTE 2: according to memcache protocol documentation, a value greater than 30 days (2592000 seconds) specifies absolute UNIX time. smaller values are relative to the time of the update. so like, know which one you're doing or chaos ensues πŸ“

🌈 MEMCACHE KEY PARAMETERS 🌈

πŸ’œ key_digest (default: empty)

after processing the key_format setting, and before sending a request to the memcache server, run the key through the named message digest algorithm and convert the result to lowercase hexadecimal characters. this prevents a database access error when keys may exceed the memcache server's key length limit (usually, 250 bytes). specify the name of a message digest algorithm that is supported by OpenSSL, for example, sha256. πŸ’…

this feature is available in Postfix 3.11 and later, and requires that Postfix is built with TLS support.

πŸ’œ key_format (default: %s)

format of the lookup and update keys that the Postfix memcache client sends to the memcache server. by default, these are the same as the lookup and update keys that the memcache client receives from Postfix applications. no glow-up needed, but the option is there πŸŽ€

NOTE 1: the key_format feature is not used for backup database requests.
NOTE 2: when multiple tables share the same memcache database, each table should prepend its own unique string to the lookup key. otherwise, automatic postscreen(8) or verify(8) cache cleanup may not work.

examples, so cute:

key_format = aliases:%s
key_format = verify:%s
key_format = postscreen:%s

the key_format parameter supports the following '%' expansions:

  • %% β€” this is replaced by a literal '%' character.
  • %s β€” this is replaced by the memcache client input key.
  • %u β€” when the input key is an address of the form user@domain, %u is replaced by the SQL quoted local part of the address. otherwise, %u is replaced by the entire search string. if the localpart is empty, a lookup is silently suppressed and returns no results (an update is skipped with a warning).
  • %d β€” when the input key is an address of the form user@domain, %d is replaced by the domain part of the address. otherwise, a lookup is silently suppressed and returns no results (an update is skipped with a warning).
  • %[SUD] β€” the upper-case equivalents of the above expansions behave in the key_format parameter identically to their lower-case counter-parts.
  • %[1-9] β€” the patterns %1, %2, ... %9 are replaced by the corresponding most significant component of the input key's domain. if the input key is user@mail.example.com, then %1 is com, %2 is example and %3 is mail. if the input key is unqualified or does not have enough domain components to satisfy all the specified patterns, a lookup is silently suppressed and returns no results (an update is skipped with a warning).

πŸ’œ domain (default: no domain list)

this feature can significantly reduce database server load. we love efficiency, we love a lazy queen 😌

specify a list of domain names, paths to files, or "type:table" databases. when specified, only fully qualified search keys with a non-empty localpart and a matching domain are eligible for lookup or update: bare 'user' lookups, bare domain lookups and "@domain" lookups are silently skipped (updates are skipped with a warning). example:

domain = example.com, hash:/etc/postfix/searchdomains

πŸ¦‹ MEMCACHE ERROR CONTROLS πŸ¦‹

  • data_size_limit (default: 10240) β€” the maximal memcache reply data length in bytes.
  • line_size_limit (default: 1024) β€” the maximal memcache reply line length in bytes.
  • max_try (default: 2) β€” the number of times to try a memcache command before giving up. the memcache client does not retry a command when the memcache server accepts no connection. it said no and meant it πŸ™ˆ
  • retry_pause (default: 1) β€” the time in seconds before retrying a failed memcache command.
  • timeout (default: 2) β€” the time limit for sending a memcache command and for receiving a memcache reply.

πŸ’€ BUGS πŸ’€

the Postfix memcache client cannot be used for security-sensitive tables such as alias_maps (these may contain "|command and "/file/name destinations), or virtual_uid_maps, virtual_gid_maps and virtual_mailbox_maps (these specify UNIX process privileges for "/file/name" destinations). in a typical deployment a memcache database is writable by any process that can talk to the memcache server; in contrast, security-sensitive tables must never be writable by the unprivileged Postfix user. this one's serious, bestie, do not play 🚨

the Postfix memcache client requires additional configuration when used as postscreen(8) or verify(8) cache. for details see the backup and ttl parameter discussions in the MEMCACHE MAIN PARAMETERS section above.


🌸 SEE ALSO 🌸


πŸ“š README FILES πŸ“š

use "postconf readme_directory" or "postconf html_directory" to locate this information.

  • DATABASE_README, Postfix lookup table overview
  • MEMCACHE_README, Postfix memcache client guide

⭐ LICENSE ⭐

The Secure Mailer license must be distributed with this software.


πŸ’« HISTORY πŸ’«

Memcache support was introduced with Postfix version 2.9. ancient. iconic. a legend 🫢


πŸŽ€ AUTHOR(S) πŸŽ€

Wietse Venema
IBM T.J. Watson Research
P.O. Box 704
Yorktown Heights, NY 10598, USA

Wietse Venema
Google, Inc.
111 8th Avenue
New York, NY 10011, USA

and that's the whole page, bestie!! this was MEMCACHE_TABLE(5) straight out of the File Formats Manual β€” postmap it, cache it, keep it in the group chat πŸ’–βœ¨ mwah πŸ’…πŸ¦‹

πŸ“¦ where this page comes from