dsh-fastswitch:更快切换会话窗口与去重只读 RPC 请求

dsh-fastswitch 是一个 DeepSeek Harness 客户端插件,通过重写会话切换时的历史窗口大小(50→20)和包装 window.fetch 实现只读 RPC 去重与缓存,提升首次加载速度。配置通过 localStorage 完成,安装后立即生效,适合需要快速切换长对话会话的开发者。

Read More
dsh-readcache: Version Token Validation Cache for DSH read Tool

`dsh-readcache` is an in-process result cache plugin for the DSH read tool, designed to address the I/O and rendering overhead caused by agents repeatedly re-reading unchanged files during long sessions. Its core features include using version tokens (file metadata) validation to ensure cache consistency, supporting agent isolation to prevent race conditions, and managing memory with an LRU policy. It intercepts the event waterfall and returns a cache hit only when the file is unchanged and the secondary stat validation passes, significantly improving performance. After installation, it can be monitored and managed with the `stats` and `clear` commands.

Read More
FastAPI + Redis: Basic Application of Caching and State Management

Web development often faces challenges of handling rapid request responses and sharing temporary state across multiple requests. The combination of FastAPI (a high-performance asynchronous framework) and Redis (an in-memory database) effectively addresses these issues. FastAPI supports high concurrency, while Redis, with its fast read/write speed and expiration time features, can cache frequently accessed, low-updating data (such as Fibonacci calculation results) to reduce redundant computations and store temporary states (such as user access counters) for cross-request sharing. This article introduces environment setup (installing FastAPI, Redis client, and starting Redis), basic connections (using utility functions to manage Redis clients with `decode_responses=True` to ensure string results), and demonstrates applications through two examples: caching (Fibonacci calculation results) and state management (user access counts). It also mentions dependency injection for code optimization and notes on Redis persistence, connection pooling, and key naming conventions in production environments.

Read More
FastAPI State Management: Simple Implementation of Global Variables and Caching

In FastAPI, two common approaches for state management are global variables and caching. Global variables are the simplest way to share state, usable directly in single-process environments but requiring asyncio.Lock to prevent race conditions in multi-request scenarios. Their limitations include process isolation issues, memory dependency, and data loss risks. Caching is more efficient and categorized into three types: in-memory caching (using dictionaries or the cachetools library, supporting LRU/TTL strategies), and distributed caching (e.g., Redis, suitable for cross-service sharing and persistence). Comparison: Global variables suit single-process, simple scenarios, while caching is ideal for high-frequency access, distributed systems, or data requiring persistence. Practical recommendations: Use global variables or cachetools in development, and distributed caches like Redis in production to avoid cross-process issues with global variables.

Read More