VapeCache.Features.Search
1.2.22
dotnet add package VapeCache.Features.Search --version 1.2.22
NuGet\Install-Package VapeCache.Features.Search -Version 1.2.22
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VapeCache.Features.Search" Version="1.2.22" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VapeCache.Features.Search" Version="1.2.22" />
<PackageReference Include="VapeCache.Features.Search" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VapeCache.Features.Search --version 1.2.22
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: VapeCache.Features.Search, 1.2.22"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VapeCache.Features.Search@1.2.22
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VapeCache.Features.Search&version=1.2.22
#tool nuget:?package=VapeCache.Features.Search&version=1.2.22
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
VapeCache.Features.Search
Typed RediSearch helpers for HASH-backed VapeCache search projections.
Install
dotnet add package VapeCache.Features.Search
What This Package Is For
- denormalized HASH documents that RediSearch can index efficiently
- typed
TEXT,TAG, andNUMERICschemas - query-building helpers for exact-match and range-heavy workloads
- search-result cache key/tag conventions that work with
VapeCache.Features.Invalidation
Recommended Enterprise Pattern
Use this package for projection search, not as a generic document database:
- Write the authoritative order/cart/session state with the right Redis data type.
- Maintain a small HASH projection for the searchable slice.
- Index that HASH prefix with RediSearch.
- Cache hot query-result pages in VapeCache using search tags/zones.
- Invalidate those result pages instantly with policy-driven invalidation when the projection changes.
For the grocery receipt-check use case, that means indexing receipt/order summary projections, not every cart mutation as a giant blob.
Example
builder.Services.AddVapeCache(builder.Configuration);
builder.Services.AddVapeCacheInvalidation();
builder.Services.AddVapeCacheSearch();
builder.Services.AddSingleton<IRedisHashSearchDocumentMapper<ReceiptSearchDocument>, ReceiptSearchDocumentMapper>();
public sealed record ReceiptSearchDocument(
string OrderId,
string ShopperId,
string StoreId,
string ReceiptStatus,
decimal Subtotal,
long CheckedOutTicks,
string SearchText);
public sealed class ReceiptSearchDocumentMapper : IRedisHashSearchDocumentMapper<ReceiptSearchDocument>
{
public RedisSearchIndexDefinition Index { get; } = new(
indexName: "idx:grocery:receipts",
documentKeyPrefix: "receipt:search:doc:",
fields:
[
RedisSearchFieldDefinition.Tag("orderId", sortable: true),
RedisSearchFieldDefinition.Tag("shopperId"),
RedisSearchFieldDefinition.Tag("storeId"),
RedisSearchFieldDefinition.Tag("receiptStatus"),
RedisSearchFieldDefinition.Numeric("subtotal", sortable: true),
RedisSearchFieldDefinition.Numeric("checkedOutTicks", sortable: true),
RedisSearchFieldDefinition.Text("searchText", weight: 2.0)
]);
public string GetDocumentId(ReceiptSearchDocument document) => document.OrderId;
public IReadOnlyList<RedisSearchHashFieldValue> MapFields(ReceiptSearchDocument document) =>
[
new("orderId", document.OrderId),
new("shopperId", document.ShopperId),
new("storeId", document.StoreId),
new("receiptStatus", document.ReceiptStatus),
new("subtotal", document.Subtotal.ToString(System.Globalization.CultureInfo.InvariantCulture)),
new("checkedOutTicks", document.CheckedOutTicks.ToString(System.Globalization.CultureInfo.InvariantCulture)),
new("searchText", document.SearchText)
];
}
var store = app.Services.GetRequiredService<IRedisHashSearchDocumentStore<ReceiptSearchDocument>>();
await store.EnsureIndexAsync(ct);
var query = new RedisSearchQueryBuilder()
.Tag("shopperId", shopperId)
.Tag("receiptStatus", "cleared")
.NumericRange("checkedOutTicks", min: DateTime.UtcNow.AddHours(-2).Ticks)
.Build(offset: 0, count: 20);
var ids = await store.SearchIdsAsync(query, ct);
Compatibility Contract
- This package is optimized for Redis HASH projections plus RediSearch indexes.
- It is meant for operational search and lookup workloads, not full OLAP or arbitrary document querying.
- Result-page caching and invalidation are first-class; backend storage-format parity with unrelated search systems is not a goal.
Invalidation Integration
public sealed class ReceiptFlaggedInvalidationPolicy : ICacheInvalidationPolicy<ReceiptFlagged>
{
public ValueTask<CacheInvalidationPlan> BuildPlanAsync(ReceiptFlagged eventData, CancellationToken ct = default)
=> ValueTask.FromResult(new CacheInvalidationPlanBuilder()
.AddSearchZone("idx:grocery:receipts")
.AddSearchIndexTag("idx:grocery:receipts")
.AddSearchScopeTag("idx:grocery:receipts", "shopperId", eventData.ShopperId)
.AddSearchEntityTag("idx:grocery:receipts", "order", eventData.OrderId)
.AddSearchDocumentKey(RedisSearchConventions.DocumentKey("receipt:search:doc:", eventData.OrderId))
.Build());
}
Docs
- Redis search guide: https://github.com/haxxornulled/VapeCache/blob/main/docs/REDIS_SEARCH.md
- Cache invalidation guide: https://github.com/haxxornulled/VapeCache/blob/main/docs/CACHE_INVALIDATION.md
- Package matrix: https://github.com/haxxornulled/VapeCache/blob/main/docs/NUGET_PACKAGES.md
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Options (>= 10.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.7)
- VapeCache.Abstractions (>= 1.2.22)
- VapeCache.Features.Invalidation (>= 1.2.22)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
See GitHub releases and docs/UPGRADE_NOTES.md for release-specific notes.