NCache 是一个速度极快且可扩展的 .NET 内存分布式缓存,它原生支持容器化环境。它可以帮助您解决数据库扩展瓶颈,并在高并发容器环境中线性扩展应用程序。您可以下载 Windows 安装程序。 (.msi) 并在 Windows 上安装。或者,您可以通过部署 NCache 在 Docker 容器中。
行业标准入门方法 NCache 是获取一个预建的 NCache Docker 镜像 来自 Docker 集线器。 这些 Docker 镜像预装了 NCache它提供了一个即用型分布式缓存,在 .NET 密集型环境中性能优于传统的内存缓存解决方案。只需使用“docker pull”命令即可将其安装到您的环境中。这确保了与企业级 CI/CD 流水线的无缝集成。
NCache 在基于 Ubuntu 的 Linux 上以 Docker 镜像的形式提供。对于其他 Linux 版本,请使用 Docker 文件 提供 Alachisoft 并根据您喜欢的 Linux 版本进行修改。运行 NCache Docker 为 .NET 应用程序保留了其标志性的亚毫秒级延迟和线性可扩展性。
在大多数情况下,预先构建的 NCache Docker Hub 上的镜像足以满足快速部署的需求。但在某些情况下,你可能需要创建一个 自定义 Docker 镜像 其中包括您自己的软件或标准操作系统软件的其他变体。
这方面的一个例子是 Linux 的风格。 NCache Docker Hub 上的 Docker Image 使用 Debian Linux,但您可能需要另一种风格的 Linux NCache 服务器; NCache 适用于多种 Linux 风格。 或者,您可能希望为您的应用程序服务器创建一个自定义 Docker 映像(NCache 客户端)不仅包含您自己的应用程序,还包含 NCache 客户端软件。这种方法可以优化容器启动时间,并确保开发和生产环境的一致性。
在所有此类情况下, Alachisoft 为您提供各种 Dockerfile,您可以编辑和自定义以满足您的需求。
您可以编辑以创建自定义 Docker 映像的这些 Dockerfile 的示例如下。
一个典型的 Dockerfile NCache NCache 服务器 它非常适合高流量微服务、ASP.NET Core 会话提供程序和实时发布/订阅消息传递。它的外观如下:
# Setting base image for NCache.
FROM ubuntu:22.04
# Setting work directory to copy setups and resources for configuring NCache.
WORKDIR /app
# Make sure your machine has access to internet for installation of packages
# Make sure that the folder ("resources") exist in the same directory as the Dockerfile.
# Make sure that "ipbinding.sh" script resides in the "resources" folder.
# Make sure that "installncache.sh" script resides in the "resources" folder.
# Make sure that NCache Linux setup (.tar.gz) resides in the "resources" folder. It can be downloaded from https://www.alachisoft.com/download-ncache.html.
# Copying resources and setups into the work directory of the container.
COPY resources .
# Exposing ports used by NCache for communication.
EXPOSE 8250-8260 9800 7800-7900 8300-8400 9900 10000-10100
# Installing prerequisite ...
RUN apt-get update && apt-get install -y \
procps \
ed \
apt-transport-https \
curl \
libicu-dev \
&& rm -rf /var/lib/apt/lists/*
# Installing NCache Linux setup (.tar.gz).
# The parameter "--firstname" represents the first name of the user.
# The parameter "--lastname" represents the last name of the user.
# The parameter "--company" Provide your company name.
# The parameter "--email" Provide your email address.
# The parameter "--installkey" Installation key provided by alachisoft.com.
RUN chmod -R 775 /app \
&& ./installncache.sh --firstname "YOUR_FIRST_NAME" --lastname "YOUR_LAST_NAME" --company "YOUR_COMPANY" --email "YOUR_EMAIL" --installkey "******" --installmode "server" \
&& rm -rf /var/lib/apt/lists/*
# Switching the current user to ncache user
USER ncache
# Entry point for the container, once all the required configurations have been made.
ENTRYPOINT ["/app/startup.sh"]