· ☕ 10 分钟

https://redis.io/topics/cluster-spec

Implemented subset

Redis Cluster implements a concept called hash tags that can be used in order to force certain keys to be stored in the same hash slot. However during manual resharding, multi-key operations may become unavailable for some time while single key operations are always available.

Clients and Servers roles in the Redis Cluster protocol

In Redis Cluster nodes are responsible for holding the data, and taking the state of the cluster, including mapping keys to the right nodes. Cluster nodes are also able to auto-discover other nodes, detect non-working nodes, and promote replica nodes to master when needed in order to continue to operate when a failure occurs.


· ☕ 6 分钟

我是一个 Java 程序员,现在想系统学习一下 Rust。

作为一名经验丰富的 Java 程序员,您已经掌握了编程的核心概念(如变量、循环、函数、面向对象等),这会大大加速您的学习进程。然而,Rust 的核心理念——所有权(Ownership)借用(Borrowing)生命周期(Lifetimes)——对您来说将是全新的,也是学习的重点和难点。


· ☕ 1 分钟
  • 微服务各种流控技术
    *

  • 分布式一致性技术

    • 数据一致性协议
  • Java

    • 网络 Netty
    • Thread Pool
  • DB
    *


· ☕ 0 分钟

· ☕ 6 分钟
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from langchain.llms import Ollama
from langchain.embeddings import OllamaEmbeddings
from langchain.chains import RetrievalQA
from langchain.vectorstores import FAISS
from langchain.text_splitter import CharacterTextSplitter
from langchain.document_loaders import TextLoader

# 加载本地模型
llm = Ollama(model="llama2")
embeddings = OllamaEmbeddings(model="llama2")

# 加载文档
loader = TextLoader("your_knowledge_base.txt")
documents = loader.load()

# 切分文本
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
texts = text_splitter.split_documents(documents)

# 创建向量数据库
db = FAISS.from_documents(texts, embeddings)

# 创建问答链
qa = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=db.as_retriever())

# 提问
query = "你的问题是什么?"
result = qa.run(query)

print(result)

FAISS.from_documents()

上面程序中,FAISS.from_documents 是什么作用?


· ☕ 6 分钟

HTTP with SSE(v2024-11-05)

https://modelcontextprotocol.io/specification/2024-11-05/basic/transports#http-with-sse

The server MUST provide two endpoints:

  1. An SSE endpoint, for clients to establish a connection and receive messages from the server
  2. A regular HTTP POST endpoint for clients to send messages to the server

双连接,一个SSE,一个POST。 SSE 用于服务器推送,POST用于客户端发送。