Skip to content

Commit

Permalink
📝 update config docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu authored Nov 24, 2024
1 parent 7cb51a0 commit 177a8ad
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docs/usage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,51 @@ The `cache_strategy` option defines how to cache the tokens or http responses. Y
Available built-in cache strategies:

- `MemCacheStrategy`: Cache the data in memory.

Normally, you do not need to specifically use this cache strategy. It is used by default.

```python
from githubkit.cache import DEFAULT_CACHE_STRATEGY, MemCacheStrategy

# Use the default cache strategy
github = GitHub(cache_strategy=DEFAULT_CACHE_STRATEGY)
# Or you can initialize another MemCacheStrategy instance
# this will create a new cache instance and not share the cache with the global one
github = GitHub(cache_strategy=MemCacheStrategy())
```

- `RedisCacheStrategy`: Cache the data in Redis (Sync only).

To cache the data in Redis (Sync only), you need to provide a redis client to the `RedisCacheStrategy`. For example:

```python
from redis import Redis

github = GitHub(
cache_strategy=RedisCacheStrategy(
client=Redis(host="localhost", port=6379)
)
)
```

Note that using this sync only cache strategy will cause the `GitHub` instance to be sync only.

- `AsyncRedisCacheStrategy`: Cache the data in Redis (Async only).

To cache the data in Redis (Async only), you need to provide an async redis client to the `AsyncRedisCacheStrategy`. For example:

```python
from redis.asyncio import Redis

github = GitHub(
cache_strategy=AsyncRedisCacheStrategy(
client=Redis(host="localhost", port=6379)
)
)
```

Note that using this async only cache strategy will cause the `GitHub` instance to be async only.

### `http_cache`

The `http_cache` option enables the http caching feature powered by [Hishel](https://hishel.com/) for HTTPX. GitHub API limits the number of requests that you can make within a specific amount of time. This feature is useful to reduce the number of requests to GitHub API and avoid hitting the rate limit.
Expand All @@ -92,6 +134,12 @@ Available built-in throttlers:

- `LocalThrottler`: Control the request concurrency in the local process / event loop.

```python
from githubkit.throttling import LocalThrottler

github = GitHub(throttler=LocalThrottler(100))
```

### `auto_retry`

The `auto_retry` option enables request retrying when rate limit exceeded and server error encountered. See [Auto Retry](./auto-retry.md) for more infomation.
Expand Down

0 comments on commit 177a8ad

Please sign in to comment.