Skip to content

Commit b088d33

Browse files
committed
docs: caching documentation
1 parent 73e6234 commit b088d33

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,29 @@ client.auth.universal_auth.login(
4545
secrets = client.secrets.list_secrets(project_id="<project-id>", environment_slug="dev", secret_path="/")
4646
```
4747

48+
## InfisicalSDKClient Parameters
49+
50+
The `InfisicalSDKClient` takes the following parameters, which are used a global configuration.
51+
52+
- **host** (`str`, _Optional_): The host URL for your Infisical instance. Defaults to `https://app.infisical.com`.
53+
- **token** (`str`, _Optional_): Specify a authentication token to use for all requests. If provided, you will not need to call any of the `auth` methods. Defaults to `None`
54+
- **cache_ttl** (`int`, _Optional_): The SDK has an inbuilt client-side cache mechanism for secrets, which greatly improves speed for the secret methods. By default secrets are cached for 5 minutes. You can disable caching by setting `cache_ttl` to `None`. The value is in seconds, so `300` equates to 5 minutes caching TTL. Default is `300` seconds.
55+
56+
```python
57+
client = InfisicalSDKClient(
58+
host="https://app.infisical.com", # Defaults to https://app.infisical.com
59+
token="<optional-auth-token>" # If not set, use the client.auth() methods.
60+
cache_ttl = 300 # `None` to disable caching
61+
)
62+
```
63+
4864
## Core Methods
4965

5066
The SDK methods are organized into the following high-level categories:
5167

5268
1. `auth`: Handles authentication methods.
5369
2. `secrets`: Manages CRUD operations for secrets.
70+
3. `kms`: Perform cryptographic operations with Infisical KMS.
5471

5572
### `auth`
5673

infisical_sdk/client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
from infisical_sdk.util import SecretsCache
88

99
class InfisicalSDKClient:
10-
def __init__(self, host: str, token: str = None, cache_ttl: int | None = 300):
10+
def __init__(self, host: str, token: str = None, cache_ttl: int = 300):
11+
"""
12+
Initialize the Infisical SDK client.
13+
14+
:param str host: The host URL for your Infisical instance. Will default to `https://app.infisical.com` if not specified.
15+
:param str token: The authentication token for the client. If not specified, you can use the `auth` methods to authenticate.
16+
:param int cache_ttl: The time to live for the secrets cache. This is the number of seconds that secrets fetched from the API will be cached for. Set to `None` to disable caching.
17+
"""
18+
1119
self.host = host
1220
self.access_token = token
1321

infisical_sdk/util/secrets_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pickle
99

1010
class SecretsCache:
11-
def __init__(self, ttl_seconds: int | None = 300) -> None:
11+
def __init__(self, ttl_seconds: int = 300) -> None:
1212
if ttl_seconds is None or ttl_seconds <= 0:
1313
self.enabled = False
1414
return

sink/example.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ def random_string(length: int = 10) -> str:
2424

2525

2626

27-
28-
2927
################################################# SECRET TESTS #################################################
3028

3129
new_secret = sdkInstance.secrets.create_secret_by_name(

0 commit comments

Comments
 (0)