Skip to main content

High-performance distributed key-value cache

Docs PyPI PyPI - Python Version PyPI - Downloads GitCode commit activity license


🔄Latest News

  • [2025/12] MemCache已作为vllm-ascend backend使能大模型推理加速,详情查看vllm-ascend开源社区,使用示例

  • [2025/11] MemCache项目于2025年11月开源,开源社区地址为:https://gitcode.com/Ascend/memcache

🔜 Roadmap

MemCache roadmap和版本分支策略详见: Roadmap

🎉概述

MemCache是针对LLM推理、GR推理场景设计的高性能分布式KVCache存储引擎,其主要特性包括:

  • 基于对象操作的API:支持批量和非批量的put/get/exist/remove操作,支持多层结构的KV Block读写接口。
  • 支持多副本:单个对象支持多副本放置到不同的LocalService,默认是单副本,支持put接口指定副本数量。
  • 高带宽低时延:使用 MemFabric 作为多级内存和异构网络传输的底座,在Ascend硬件上,基于device_rdma(A2)、device_sdma(A3)、host_rdma(A2/A3) 等路径提供OneCopy跨机跨介质数据直接访问能力,满足高带宽,低时延的读写性能述求。在鲲鹏硬件上,支持host_urma(K5)。支持host_shm实现同节点共享内存通信。
  • 支持扩缩容:支持LocalService动态加入和移除
  • HA能力:在K8S集群中,MetaService支持多活能力,支持元数据恢复,提供尽力而为的HA能力。
architecture

🧩核心组件

MemCache包含LocalService和MetaService两大核心组件:

  • MetaService:

    • 负责管理整个集群中内存池空间的分配和管理,处理LocalService的加入与退出。
    • MetaService作为独立进程运行,提供两种启动方式:python API启动;二进制启动,详见 安装部署
    • MetaService支持两种部署形态: 1、单点模式:MetaService由单个进程组成,部署方式简单,但存在单点故障的问题。如果MetaService进程崩溃或无法访问,系统将无法继续提供服务,直至重新恢复为止。 2、HA模式:该模式基于K8S的的ClusterIP Service和Lease资源构建,部署较为复杂,该模式会部署多个MetaService进程实例,实现多活高可用。部署详见 MetaService HA
  • LocalService:负责承担如下功能:

    • 客户端:作为客户端,以whl/so形式作为共享库被应用进程加载调用API
    • 内存提供者:负责提供一段连续的内存区域作为内存池空间的一部分,其内存可以被其他LocalService实例基于地址直接访问。

🔥性能表现

MemCache核心能力是提供大容量内存池和高性能的H2D、D2H、D2RH、RH2D数据访问能力,由于MemCache以 MemFabric 作为池化底座,所以支持RH2D、D2RH等OneCopy跨机跨介质数据直接访问能力,下图为RH2D对比其他中转路径的对比示意图。

RH2D

基于OneCopy跨机跨介质数据直接访问的能力,MemCache在A2/A3做了相关性能测试如下: 模拟构造DeepSeek-R1模型KV大小的block,单个block size为:61x128K + 61x16K = 8784KB ≈ 8.57MB,共122个离散地址。

  • 使用2个昇腾A2节点(每节点8张卡)组成双机内存池进行读写测试性能如下:
A2 perf
  • 使用2个昇腾A3节点(每节点8张卡16Die)组成双机内存池进行读写测试性能如下:
A3 perf

🔍目录结构

├── LICENSE                                 # LICENSE
├── .clang-format                           # 格式化配置
├── .gitmodules                             # git配置
├── .gitignore                              # git忽视配置文件
├── CMakeLists.txt                          # 项目的CMakeList
├── doc                                     # 文档目录
├── example                                 # 样例
│  ├── cpp                                  # c++样例
│  └── python                               # python样例
├── script                                  # 构建脚本
│  ├── build_and_pack_run.sh                # 编译+打包脚本
│  ├── build.sh                             # 编译脚本
│  ├── run_ut.sh                            # 编译+运行ut脚本
├── test                                    # test目录
│  ├── python                               # python测试用例
│  ├── k8s_deploy                           # k8s ha样例脚本
│  └── ut                                   # 单元测试用例
├── src                                     # 源码
│  ├── memcache                             # MemCache 源码
├── config                                  # 配置目录
│  ├── mmc-local.conf                       # 本地服务配置文件模板
│  ├── mmc-meta.conf                        # meta服务配置文件模板
├── README.md

🚀快速入门

请访问以下文档获取简易教程。

  • 编译部署:介绍组件编译和安装教程。
  • 配置文件:涉及MetaService、LocalService公共配置
  • 样例执行:介绍如何端到端执行样例代码,包括C++和Python样例。
  • [最佳实践]:推出中...

📑学习教程

  • c++接口:C++接口介绍以及C++接口对应的API列表
  • python接口:python接口介绍以及python接口对应的API列表

📦软件硬件配套说明

  • MemCache软件依赖 MemFabric,相关配套与MemFabric相同

📌FAQ

常见问题请参考:FAQ

📝相关信息

Metadata

Release files for memcache-hybrid 1.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for memcache-hybrid 1.1.6
File
memcache_hybrid-1.1.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
memcache_hybrid-1.1.6-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ ARM64, Linux glibc 2.26+ ARM64 Details
memcache_hybrid-1.1.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
memcache_hybrid-1.1.6-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ ARM64, Linux glibc 2.26+ ARM64 Details
memcache_hybrid-1.1.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
memcache_hybrid-1.1.6-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details
memcache_hybrid-1.1.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
memcache_hybrid-1.1.6-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ ARM64, Linux glibc 2.26+ ARM64 Details

Total release size: 31.6 MB

Release files / memcache_hybrid-1.1.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL memcache_hybrid-1.1.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 4.1 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d18a2066286671f00b7e420f7093fcac9c7374d59f50e72e543b07ccc870cf3f
BLAKE2b-256 checksum
How to use checksums
1b9ecfa619a38b907fddfb468960ed92d961b07c3e04edc3381551ded2d723ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / memcache_hybrid-1.1.6-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL memcache_hybrid-1.1.6-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 3.8 MB
Tags CPython 3.13 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
71573763f50c32da6aff3f151e145096b6322bb334ac52c2fd2119bc9cf90009
BLAKE2b-256 checksum
How to use checksums
80ea722c68e346705dafeef6b205add281fb585530488f8749d110fecc2793aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / memcache_hybrid-1.1.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL memcache_hybrid-1.1.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 4.1 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
8ed26438d8b96546d6d68aa2dc15b671edb26ec9638884dd589e64a1f85e270e
BLAKE2b-256 checksum
How to use checksums
fda3f39ef7da1b4c4fc8383969867e0b2e3434780952ae6b3bb5078d1fb43673
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / memcache_hybrid-1.1.6-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL memcache_hybrid-1.1.6-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 3.8 MB
Tags CPython 3.12 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
4beb2ed72f761580587edfe55cf3dea56860aeed141997b20a4382db1555b8ef
BLAKE2b-256 checksum
How to use checksums
dd4bd058ddb4eef3edaeffdf822dcee157b56074229b6f8c12cbd5bf4d1cc02b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / memcache_hybrid-1.1.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL memcache_hybrid-1.1.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 4.1 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9f4786f80adcaec46c557c65c376cf450b03554f15787360c3c04d52621d4416
BLAKE2b-256 checksum
How to use checksums
8730e63adc373afcaeef9d4b8b09d05942895088493f7007b4f6534dc7c993f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / memcache_hybrid-1.1.6-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL memcache_hybrid-1.1.6-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 3.8 MB
Tags CPython 3.11 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
6909735180551f90d0deb92fdf6e3ed6e998ab1543a65d84124520b18ee5b5f9
BLAKE2b-256 checksum
How to use checksums
2a8d0168198f5e6b02b46574f7f8a119884c96cab28ec8e90c61cf8e172fce87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / memcache_hybrid-1.1.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL memcache_hybrid-1.1.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 4.1 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ee92ef1e0d695e2dfba188d4c435d5fa18b53ae9b771df2e4086f96e93e98f5e
BLAKE2b-256 checksum
How to use checksums
a09b6a27bcd6a6987d27f35ed4a0686a5d79014a5ec08f9b0abf5b69343ab624
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / memcache_hybrid-1.1.6-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL memcache_hybrid-1.1.6-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 3.8 MB
Tags CPython 3.10 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
adf6d51d094c1e43dee9822a4b298c34aea7f12695f219ee0a0e5609228f62b3
BLAKE2b-256 checksum
How to use checksums
795a73a3a66d3abbdcbec18013287befef5cb9ea5641cbcfa31d53586913a56f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Security for memcache-hybrid 1.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page