@shopify/async-memcached
Aasync-memcache is an async memcached client implementation for Tokio.
Install
agr install @shopify/async-memcached --target cursorWrites 1 file into .cursor/rules/, pinned to git-44265ab0.
- .cursorrules
Document
Code Style and Structure:
- Write concise, technical Rust code with accurate examples
- Prefer iteration and modularization over code duplication
- Use descriptive variable names with auxiliary verbs (e.g., is_loading, has_error)
Naming Conventions:
- Use lowercase with underscores for directories (e.g., components/auth_wizard)
Error Handling and Validation:
- Prioritize error handling: handle errors and edge cases early in the code
- Use early returns and guard clauses
- Implement proper error logging and user-friendly messages
Performance Optimization:
- try to maintain zero copy for all bytes
- try to avoid dynamic functions
- always prefer approaches that do not require allocation of new Strings or Vecs unless specifically requested
Follow Rust docs for style, examples, and code
DO NOT GIVE ME HIGH LEVEL SHIT, IF I ASK FOR FIX OR EXPLANATION, I WANT ACTUAL CODE OR EXPLANATION! I DON'T WANT "Here's how you can blablabla"
- Be casual unless otherwise specified
- Be terse
- Suggest solutions that I didn't think about-anticipate my needs
- Treat me as an expert
- Be accurate and thorough
- Give the answer immediately. Provide detailed explanations and restate my query in your own words if necessary after giving the answer
- Value good arguments over authorities, the source is irrelevant
- Consider new technologies and contrarian ideas, not just the conventional wisdom
- You may use high levels of speculation or prediction, just flag it for me
- No moral lectures
- Discuss safety only when it's crucial and non-obvious
- If your content policy is an issue, provide the closest acceptable response and explain the content policy issue afterward
- Cite sources whenever possible at the end, not inline
- No need to mention your knowledge cutoff
- No need to disclose you're an AI
- Please respect my prettier preferences when you provide code.
- Split into multiple responses if one response isn't enough to answer the question. If I ask for adjustments to code I have provided you, do not repeat all of my code unnecessarily. Instead try to keep the answer brief by giving just a couple lines before/after any changes you make. Multiple code blocks are ok.
Repository README
Describes Shopify/async-memcached as a whole, which may contain artifacts other than this one. Where this artifact had no useful description of its own, its summary was taken from here.
async-memcache
async-memcache is an async memcached client implementation for Tokio.
Warning: This is a work in progress crate.
Testing
The default test suite does not require memcached to be running. It will ignore tests that require memcached to be running.
cargo test
For the full test suite, you need to have memcached installed and running.
memcached -p 11211 -t 10 -c 10000 -m 1024
cargo test && cargo test -- --ignored
Benchmark
To run the benchmark, you need to have memcached installed and running.
memcached -p 11211 -t 10 -c 10000 -m 1024
cargo bench
Examples
You can run the examples with cargo run --example <example-name>. Examples require a running memcached server.
TCP
Run a memcached server (with optional very verbose flag) that accepts a TCP connection and execute the basic examples:
memcached -vv
cargo run --package async-memcached --example basic
Unix Domain Socket
Run a memcached server (with optional very verbose flag) that accepts a UDS connection and execute the UNIX examples:
memcached -vv -s /tmp/memcached.sock
cargo run --package async-memcached --example unix
Profiling
Install samply with cargo install samply.
samply record cargo run --package async-memcached --example unix
Features
This crate only targets the ASCII protocol, as the binary protocol has been deprecated and is no longer actively being improved.
- TCP connection
- UDP connection
- UNIX domain socket connection
- Authentication
- TLS
Releasing a new version
Developers should keep a running log of changes being made with each PR in CHANGELOG.md, under the [Unreleased] - ReleaseDate
header to ensure that accurate change records are kept as part of the release cycle.
To release a new version of this crate, you must be part of the Owners group listed on crates.io. If you are not part of this group and require a release that includes recently merged changes, please open an issue on Github.
When using the cargo-release crate to release a new version, the version field in Cargo.toml will be bumped automatically according to the <LEVEL> argument that has been provided. Additionally, CHANGELOG.md will have version and date fields updated
automatically. See the cargo-release documentation for more info on versioning and options.
cargo publish workflow:
- Ensure the your
mainbranch is up to date:
git checkout main
git pull
- Checkout a new branch with the release version name:
git checkout -b "release v<VERSION>"
- Update the
versionfield inCargo.tomlto reflect the desired new version of the crate, following semantic versioning best practices. - Update the
CHANGELOG.mdsuch that the latest changes are under a header with the new version & release date:
## [Unreleased] - ReleaseDate
### Added
- a cool new feature
### Changed
- something to be more optimized
Should be updated to:
## [Unreleased] - ReleaseDate
## [Major.Minor.Patch] - 20YY-MM-DD
### Added
- a cool new feature
### Changed
- something to be more optimized
- Push your changes to the remote, get approval and merge your PR
- Update your
mainbranch again:
git checkout main
git pull
- Run
cargo publish --dry-runto perform a dry run, ensuring that your publishing process will proceed as expected. - Run
cargo publishto publish the new version of this crate to crates.io.
cargo release workflow:
- Ensure the
mainbranch is up to date:
git checkout main
git pull
- Checkout a new branch with the release version name:
git checkout -b "release v<VERSION>"
- Open a PR on GitHub and fill out the PR template for a release. Provide the
cargo releasedryrun output in the PR body.
$ cargo release patch -v
[2024-09-09T17:37:47Z DEBUG reqwest::connect] starting new connection: https://index.crates.io/
[2024-09-09T17:37:48Z DEBUG cargo_release::steps] Files changed in async-memcached since v0.3.0: [
"/async-memcached/CHANGELOG.md",
"/async-memcached/benches/bench.rs",
"/async-memcached/src/connection.rs",
"/async-memcached/src/lib.rs",
"/async-memcached/src/value_serializer.rs",
]
[2024-09-09T17:37:48Z DEBUG globset] glob converted to regex: Glob { glob: "**/*", re: "(?-u)^(?:/?|.*/)[^/]*$", opts: GlobOptions { case_insensitive: false, literal_separator: true, backslash_escape: true, empty_alternates: false }, tokens: Tokens([RecursivePrefix, ZeroOrMore]) }
[2024-09-09T17:37:48Z DEBUG globset] built glob set; 0 literals, 1 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 1 regexes
Upgrading async-memcached from 0.3.0 to 0.3.1
[2024-09-09T17:37:48Z DEBUG cargo_release::ops::cargo] change:
--- /async-memcached/Cargo.toml original
+++ /async-memcached/Cargo.toml updated
@@ -1,6 +1,6 @@
[package]
name = "async-memcached"
-version = "0.3.0"
+version = "0.3.1"
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
edition = "2018"
readme = "README.md"
[2024-09-09T17:37:48Z DEBUG cargo_release::steps::release] updating lock file
[2024-09-09T17:37:48Z DEBUG cargo_release::ops::replace] processing replacements for file async-memcached/CHANGELOG.md
Replacing in CHANGELOG.md
--- CHANGELOG.md original
+++ CHANGELOG.md replaced
@@ -10,6 +10,8 @@
## [Unreleased] - ReleaseDate
+## [0.3.1] - 2024-09-09
+
### Changed
- `set` and `add` methods can now accept `uint`-type argument for value in addition to `&str` and `&String` types. The original implementation used an `AsRef` trait bound, which has been replaced with a custom `AsMemcachedValue` trait bound that should cover all of the applicable incoming types.
- Once your PR is approved, run
cargo release <LEVEL> -v --executeand select yes (y) to confirm that you would like to publish to crates.io. This will automatically update theversionfield inCargo.tomland replace the## [Unreleased] - ReleaseDateheader inCHANGELOG.mdwith the appropriate version and date automatically, and then publish the crate with those changes included. These changes will also be pushed to your remote branch. - Merge your PR so that
mainand the released crate version are in parity.
License
MIT
Trustgrade A
- passBody integrity
Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.
- passType matchnot applicable to this artifact type
Whether the artifact is really the kind of thing its metadata claims it is.
- passFreshness
How long since the source repository was last pushed to.
- passPrompt injection
Scans the artifact's own text for instructions aimed at your agent rather than at you.
- passLicense
Whether the source repository declares an SPDX license permissive enough to redistribute.
How the grade is calculated
Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:
- Aevery check passed
- Bone warning
- Ctwo warnings
- Dprompt injection or body integrity failed, or three warnings
- Fone of those failed, and something else is wrong
These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.
Versions
git-44265ab090ce2026-08-06