Changelog v3.1.2 (2025-12-20)
Version 3.1.2 (2025-12-20)
Performance: SIMD-Accelerated String Processing
Added SIMD (Single Instruction, Multiple Data) optimizations using SearchValues<char> for faster string processing operations. These optimizations leverage hardware vector instructions (AVX2/SSE on x64, AdvSimd on ARM) to process multiple characters simultaneously.
Optimized operations:
- PostgreSQL array to JSON conversion (
PgArrayToJsonArray): Faster parsing of array delimiters and escape sequences. - Composite type/tuple to JSON conversion (
PgUnknownToJsonArray): Accelerated tuple field parsing. - String quoting and escaping (
QuoteText): Vectorized quote detection with fast-path for strings without quotes. - Template string formatting (
FormatString): SIMD-accelerated brace detection for URL and response templates. - Pattern matching (
IsPatternMatch): Fast-path for patterns without wildcards and early-exit for non-matching prefixes.
Where you'll see improvements:
- APIs returning large PostgreSQL arrays (100+ elements): ~30-50% faster serialization
- Bulk CSV uploads with many rows: Faster delimiter detection
- Endpoints with complex URL templates: Reduced template processing overhead
- High-throughput scenarios: Lower CPU usage per request
These optimizations are automatic and require no configuration changes. Performance gains scale with input size - small inputs see modest improvements (~10-20%), while large arrays and bulk operations benefit significantly (~40-60%).
Consistent JSON Error Responses
All error responses (401 Unauthorized, 403 Forbidden, 404 Not Found, 500 Internal Server Error) now consistently return a JSON body using the RFC 7807 Problem Details format:
json
{
"type": null,
"title": "Unauthorized",
"status": 401,
"detail": null
}Previously, some error responses (particularly authorization failures) returned empty bodies or plain text. Now all endpoints return a consistent, parseable JSON error format regardless of the error type.
EnvFile Configuration Option
Added new EnvFile option to the Config section for loading environment variables from a .env file:
json
{
"Config": {
"AddEnvironmentVariables": false,
"ParseEnvironmentVariables": true,
"EnvFile": ".env"
}
}When AddEnvironmentVariables or ParseEnvironmentVariables is true and the EnvFile path is set, the application will load environment variables from the specified file. The file format supports:
KEY=VALUEpairs (one per line)- Comments (lines starting with
#) - Quoted values (both single and double quotes)
Example .env file:
code
PGHOST=localhost
PGPORT=5432
PGDATABASE=example_db
PGUSER=postgres
PGPASSWORD=postgresThe variables are loaded into the environment and made available for configuration parsing with the {ENV_VAR_NAME} syntax.
TsClient: Configurable Error Expression and Type
Added two new options to the TypeScript client code generator (TsClient) for customizing error handling in generated code:
ErrorExpression(default:"await response.json()"): The expression used to parse error responses. Allows customization for different error parsing strategies.ErrorType(default:"{status: number; title: string; detail?: string | null} | undefined"): The TypeScript type annotation for error responses.
These options are only used when IncludeStatusCode is true. Configuration example:
json
{
"ClientCodeGen": {
"IncludeStatusCode": true,
"ErrorExpression": "await response.json()",
"ErrorType": "{status: number; title: string; detail?: string | null} | undefined"
}
}Void functions and procedures now also return the error object when IncludeStatusCode is true.
HybridCache Support
Added HybridCache as a third caching option alongside Memory and Redis. HybridCache uses Microsoft's Microsoft.Extensions.Caching.Hybrid library to provide:
- Stampede protection: Prevents multiple concurrent requests from hitting the database when cache expires
- Optional Redis L2 backend: Can use Redis as a distributed secondary cache for sharing across instances
- In-memory L1 cache: Fast local cache for frequently accessed data
Configuration in appsettings.json:
json
{
"CacheOptions": {
"Enabled": true,
"Type": "Hybrid",
"UseRedisBackend": false,
"RedisConfiguration": "localhost:6379,abortConnect=false",
"MaximumKeyLength": 1024,
"MaximumPayloadBytes": 1048576,
"DefaultExpiration": "5 minutes",
"LocalCacheExpiration": "1 minute"
}
}Cache types:
Memory: In-process memory cache (fastest, single instance only)Redis: Distributed Redis cache (slower, shared across instances)Hybrid: HybridCache with stampede protection, optionally backed by Redis
When UseRedisBackend is false (default), HybridCache works as an in-memory cache with stampede protection. When true, it uses Redis as the L2 distributed cache for sharing across multiple application instances.
Fixed IncludeSchemaInNames option to work correctly when UseRoutineNameInsteadOfEndpoint is false (the default).