You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add Redis caching for navigation pagination (stac-utils#488)
**Related Issue(s):**
-
stac-utils#439
**Description:**
Add Redis caching support for navigation pagination to enable proper
`prev`/`next` links in STAC API responses.
**PR Checklist:**
- [x] Code is formatted and linted (run `pre-commit run --all-files`)
- [x] Tests pass (run `make test`)
- [x] Documentation has been updated to reflect changes, if applicable
- [x] Changes are added to the changelog
---------
Co-authored-by: Yuri Zmytrakov <[email protected]>
Co-authored-by: Jonathan Healy <[email protected]>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
10
10
### Added
11
11
12
12
- Environment variable `EXCLUDED_FROM_QUERYABLES` to exclude specific fields from queryables endpoint and filtering. Supports comma-separated list of fully qualified field names (e.g., `properties.auth:schemes,properties.storage:schemes`) [#489](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/489)
13
+
- Added Redis caching configuration for navigation pagination support, enabling proper `prev` and `next` links in paginated responses. [#488](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/488)
@@ -344,6 +345,32 @@ You can customize additional settings in your `.env` file:
344
345
> [!NOTE]
345
346
> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, `ES_VERIFY_CERTS` and `ES_TIMEOUT` apply to both Elasticsearch and OpenSearch backends, so there is no need to rename the key names to `OS_` even if you're using OpenSearch.
346
347
348
+
## Redis for Navigation environment variables:
349
+
These Redis configuration variables to enable proper navigation functionality in STAC FastAPI.
|`REDIS_ENABLE`| Enables or disables Redis caching for navigation. Set to `true` to use Redis, or `false` to disable. |`false`|**Required** (determines whether Redis is used at all) |
354
+
|**Redis Sentinel**||||
355
+
|`REDIS_SENTINEL_HOSTS`| Comma-separated list of Redis Sentinel hostnames/IP addresses. |`""`| Conditional (required if using Sentinel) |
356
+
|`REDIS_SENTINEL_PORTS`| Comma-separated list of Redis Sentinel ports (must match order). |`"26379"`| Conditional (required if using Sentinel) |
357
+
|`REDIS_SENTINEL_MASTER_NAME`| Name of the Redis master node in Sentinel configuration. |`"master"`| Conditional (required if using Sentinel) |
358
+
|**Redis**||||
359
+
|`REDIS_HOST`| Redis server hostname or IP address for Redis configuration. |`""`| Conditional (required for standalone Redis) |
360
+
|`REDIS_PORT`| Redis server port for Redis configuration. |`6379`| Conditional (required for standalone Redis) |
361
+
|**Both**||||
362
+
|`REDIS_DB`| Redis database number to use for caching. |`0` (Sentinel) / `15` (Standalone) | Optional |
363
+
|`REDIS_MAX_CONNECTIONS`| Maximum number of connections in the Redis connection pool. |`10`| Optional |
364
+
|`REDIS_RETRY_TIMEOUT`| Enable retry on timeout for Redis operations. |`true`| Optional |
365
+
|`REDIS_DECODE_RESPONSES`| Automatically decode Redis responses to strings. |`true`| Optional |
366
+
|`REDIS_CLIENT_NAME`| Client name identifier for Redis connections. |`"stac-fastapi-app"`| Optional |
367
+
|`REDIS_HEALTH_CHECK_INTERVAL`| Interval in seconds for Redis health checks. |`30`| Optional |
368
+
|`REDIS_SELF_LINK_TTL`| Time-to-live (TTL) in seconds for storing self-links in Redis, used for pagination caching. | 1800 | Optional |
369
+
370
+
371
+
> [!NOTE]
372
+
> Use either the Sentinel configuration (`REDIS_SENTINEL_HOSTS`, `REDIS_SENTINEL_PORTS`, `REDIS_SENTINEL_MASTER_NAME`) OR the Redis configuration (`REDIS_HOST`, `REDIS_PORT`), but not both.
373
+
347
374
## Excluding Fields from Queryables
348
375
349
376
You can exclude specific fields from being exposed in the queryables endpoint and from filtering by setting the `EXCLUDED_FROM_QUERYABLES` environment variable. This is useful for hiding sensitive or internal fields that should not be queryable by API users.
@@ -615,6 +642,19 @@ The system uses a precise naming convention:
The Redis cache stores navigation state for paginated results, allowing the system to maintain previous page links using tokens. The configuration supports both Redis Sentinel and standalone Redis setups.
648
+
649
+
Steps to configure:
650
+
1. Ensure that a Redis instance is available, either a standalone server or a Sentinel-managed cluster.
651
+
2. Establish a connection between STAC FastAPI and Redis instance by setting the appropriate [**environment variables**](#redis-for-navigation-environment-variables). These define the Redis host, port, authentication, and optional Sentinel settings.
652
+
3. Control whether Redis caching is activated using the `REDIS_ENABLE` environment variable to `True` or `False`.
653
+
4. Ensure the appropriate version of `Redis` is installed:
654
+
```
655
+
pip install stac-fastapi-elasticsearch[redis]
656
+
```
657
+
618
658
## Elasticsearch Mappings
619
659
620
660
- **Overview**: Mappings apply to search index, not source data. They define how documents and their fields are stored and indexed.
0 commit comments