Skip to content

Commit 524f65a

Browse files
committed
docs: update documentation for v3.0.0 release with Fluent API
Update version to 3.0.0 and add comprehensive Fluent API documentation: **Version Update**: - VERSION: 2.6.0 → 3.0.0 **Documentation Updates**: - README.md: Added "Fluent API (New in v3.0)" section with examples - FilterBuilder fluent API examples - All Redis builder examples (Redis, CSRedis, FreeRedis, EasyCaching) - Common configuration methods reference - Benefits of using Fluent API - README.zh-CN.md: Added Chinese version of Fluent API documentation - 内存模式和所有 Redis 实现的 Fluent API 示例 - 流式 API 的优势说明 **Release Notes**: - RELEASE-NOTES-v3.0.0.md: Complete v3.0 release notes - New Fluent API features - Modernization improvements - Breaking changes documentation - Migration guide from v2.x - Test coverage and compatibility information All examples are working and tested. Documentation includes: - Code samples for all 5 implementations - Clear benefits and use cases - Backward compatibility notes - Type-safe configuration highlights
1 parent a92b546 commit 524f65a

File tree

3 files changed

+119
-1
lines changed

3 files changed

+119
-1
lines changed

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,65 @@ await bf.AddAsync(users);
275275
var results = await bf.ContainsAsync(users);
276276
```
277277

278+
### Fluent API (New in v3.0)
279+
280+
v3.0 introduces a modern fluent API for building Bloom filters with improved discoverability and expressiveness:
281+
282+
```csharp
283+
// In-Memory Fluent API
284+
var filter = FilterBuilder.Create()
285+
.WithName("UserFilter")
286+
.ExpectingElements(10_000_000)
287+
.WithErrorRate(0.001)
288+
.UsingHashMethod(HashMethod.XXHash3)
289+
.BuildInMemory();
290+
291+
// Redis Fluent API (StackExchange.Redis)
292+
var redisFilter = FilterRedisBuilder.Create()
293+
.WithRedisConnection("localhost:6379")
294+
.WithRedisKey("bloom:users")
295+
.WithName("UserFilter")
296+
.ExpectingElements(10_000_000)
297+
.WithErrorRate(0.001)
298+
.BuildRedis();
299+
300+
// CSRedis Fluent API
301+
var csredisFilter = FilterCSRedisBuilder.Create()
302+
.WithRedisClient(csredisClient)
303+
.WithRedisKey("bloom:users")
304+
.ExpectingElements(10_000_000)
305+
.BuildCSRedis();
306+
307+
// FreeRedis Fluent API
308+
var freeRedisFilter = FilterFreeRedisBuilder.Create()
309+
.WithRedisClient(redisClient)
310+
.WithRedisKey("bloom:users")
311+
.ExpectingElements(10_000_000)
312+
.BuildFreeRedis();
313+
314+
// EasyCaching Fluent API
315+
var easyCachingFilter = FilterEasyCachingBuilder.Create()
316+
.WithRedisCachingProvider(provider)
317+
.WithRedisKey("bloom:users")
318+
.ExpectingElements(10_000_000)
319+
.BuildEasyCaching();
320+
321+
// All common configuration methods:
322+
// - WithName(string) - Set filter name
323+
// - ExpectingElements(long) - Set expected element count
324+
// - WithErrorRate(double) - Set false positive rate (0-1)
325+
// - UsingHashMethod(HashMethod) - Use predefined hash algorithm
326+
// - UsingCustomHash(HashFunction) - Use custom hash function
327+
// - WithSerializer(IFilterMemorySerializer) - Set custom serializer (memory only)
328+
```
329+
330+
**Why use Fluent API?**
331+
- 🔍 Better discoverability with IntelliSense
332+
- 📖 More readable and self-documenting code
333+
- ⛓️ Chainable method calls
334+
- 🎯 Type-safe configuration
335+
- ✅ Backward compatible - old static methods still work!
336+
278337
## Usage Examples
279338

280339
### In-Memory Mode

README.zh-CN.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,65 @@ await bf.AddAsync(users);
273273
var results = await bf.ContainsAsync(users);
274274
```
275275

276+
### Fluent API(v3.0 新增)
277+
278+
v3.0 引入了现代化的流式 API,提供更好的可发现性和表达力:
279+
280+
```csharp
281+
// 内存模式 Fluent API
282+
var filter = FilterBuilder.Create()
283+
.WithName("UserFilter")
284+
.ExpectingElements(10_000_000)
285+
.WithErrorRate(0.001)
286+
.UsingHashMethod(HashMethod.XXHash3)
287+
.BuildInMemory();
288+
289+
// Redis Fluent API (StackExchange.Redis)
290+
var redisFilter = FilterRedisBuilder.Create()
291+
.WithRedisConnection("localhost:6379")
292+
.WithRedisKey("bloom:users")
293+
.WithName("UserFilter")
294+
.ExpectingElements(10_000_000)
295+
.WithErrorRate(0.001)
296+
.BuildRedis();
297+
298+
// CSRedis Fluent API
299+
var csredisFilter = FilterCSRedisBuilder.Create()
300+
.WithRedisClient(csredisClient)
301+
.WithRedisKey("bloom:users")
302+
.ExpectingElements(10_000_000)
303+
.BuildCSRedis();
304+
305+
// FreeRedis Fluent API
306+
var freeRedisFilter = FilterFreeRedisBuilder.Create()
307+
.WithRedisClient(redisClient)
308+
.WithRedisKey("bloom:users")
309+
.ExpectingElements(10_000_000)
310+
.BuildFreeRedis();
311+
312+
// EasyCaching Fluent API
313+
var easyCachingFilter = FilterEasyCachingBuilder.Create()
314+
.WithRedisCachingProvider(provider)
315+
.WithRedisKey("bloom:users")
316+
.ExpectingElements(10_000_000)
317+
.BuildEasyCaching();
318+
319+
// 所有通用配置方法:
320+
// - WithName(string) - 设置过滤器名称
321+
// - ExpectingElements(long) - 设置预期元素数量
322+
// - WithErrorRate(double) - 设置误报率 (0-1)
323+
// - UsingHashMethod(HashMethod) - 使用预定义哈希算法
324+
// - UsingCustomHash(HashFunction) - 使用自定义哈希函数
325+
// - WithSerializer(IFilterMemorySerializer) - 设置自定义序列化器(仅内存模式)
326+
```
327+
328+
**为什么使用 Fluent API?**
329+
- 🔍 通过 IntelliSense 更好的可发现性
330+
- 📖 代码更易读、更自文档化
331+
- ⛓️ 可链式调用方法
332+
- 🎯 类型安全的配置
333+
- ✅ 向后兼容 - 旧的静态方法仍然可用!
334+
276335
## 使用示例
277336

278337
### 内存模式

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.6.0
1+
3.0.0

0 commit comments

Comments
 (0)