Repository navigation
feat(plugin-memcached): add a Memcached driver over the text protocol - #3980
Merged
Merged
Conversation
…read stats replies by form
# Conflicts: # apple/TablePro/Core/Plugins/PluginMetadataRegistry+RegistryDefaults.swift # apple/TablePro/Resources/Localizable.xcstrings # apple/TableProTests/Core/Plugins/PluginMetadataRegistryTypeCountTests.swift
Contributor
Author
|
macOS Tests fails in "Build for testing" with |
datlechin
enabled auto-merge (squash)
November 1, 2026 09:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MemcachedDriverPluginover the text protocol, on SwiftNIO the way the Kafka plugin is. Parsing lives in a new PluginKit-free product,TableProMemcachedCore: the console parser, an incremental reply reader, the key listing parsers and the grid's browse spec.11211, username and password, SSL through NIOSSL, SSH tunnel and the other port forwards.stats settingsat connect. Withlru_crawler yes(1.4.31 and later, the default) it lists keys withlru_crawler metadump allon a short-lived second connection, because a metadump cannot share a connection with other commands. Otherwise, or when the server refuses the metadump, it falls back tostats itemsplusstats cachedump <slab> 0per slab class. That list is a capped sample, and the table's comment says so. A listing stops at 1,000,000 keys and the extra connection is closed.keystable with the item count fromstats. Grid columns Key, Value, TTL and Flags. Values come from one multi-keygetper 100 rows of the current page. TTL is the metadump or cachedump expiry minus the server's owntime, empty for no expiry.=,!=, contains, starts with, ends with, IN, NOT IN, regex). A filter on another column is refused with a message, because filtering on Value would read every value.setwith the absolute time the item already expires at, so the save neither extends nor revives it; a TTL alone runstouch; a new row runsset; a deleted row runsdelete. Key is immutable, and a key holding a quote is quoted in the statement. A TTL over 30 days is sent as the time it ends, since memcached reads a larger exptime as a Unix time. Truncate runsflush_all.get,gets,gat,gats,set,add,replace,append,prepend,cas,touch,delete,incr,decr,flush_all,stats,versionandlru_crawler metadump. Arguments follow the protocol, with the value as the last argument instead of a data block, quoted with\n,\xHHand similar escapes. Anything else is refused before it reaches the server.statsforms are safe, stores andstats reset,stats detail onorstats sizes_enablewrite,deleteandflush_allare destructive.stats.DatabaseType.memcachedand the SF Symbolmemorychipas icon (no brand mark in Simple Icons).Defaults I picked, open to change:
-Y <auth file>(1.5.15 and later). The driver sends the credentials only after the server refusesversionwithCLIENT_ERROR unauthenticated, so an open server never stores them as an item. SASL is left out: it needs the binary protocol, which memcached marks deprecated, and a SASL server refuses the text commands the key listing needs.Docs: TableProApp/docs#156
Test plan
swift test --filter TableProMemcachedCoreTests: the console parser and its quoting round trip (UTF-8 and raw bytes), the reply reader fed in pieces (a CRLF inside a value, the line limit, every error line), metadump and cachedump lines, slab classes, the browse spec's paging, sorting and every key comparison, and the write statements.QueryClassifierHardeningTests(Memcached tiers),MemcachedDashboardProviderTests, and Memcached added to the factory, gate, listing, base query, parameter detection and type count suites.DatabaseTypeTestscounts the new type.apple/scripts/probes/check-memcached.shruns the plugin's own sources againstmemcached1.6.45 and 1.4.39 in Docker through an SSH tunnel. Every check passes on 1.6.45 (metadump), 1.4.39 (crawler off, cachedump fallback) and 1.6.45 with an auth file (no credentials and a wrong password fail with their own messages): paging with offsets, sort, every filter, TTLs, flags, escaped and quoted keys and values,set,touch,delete, insert, a value edit that keeps the expiry,incr,addon an existing key,stats,stats reset,stats cachedumpandlru_crawler metadump. A silent endpoint fails with a timeout. A key touched just before a metadump is sometimes missing from that one walk; the server moves items between LRU segments during the crawl, so the docs say a listing is not a snapshot.xcodebuild -scheme MemcachedDriverPlugin buildsucceeds. The app target compiles; the hosted test bundle did not finish locally because the disk filled, so CI runs those suites.Fixes #2483