Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
karpetrosyan committed Dec 9, 2023
1 parent f8b9742 commit 597a045
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/advanced/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,22 @@ Instead of just the `hashed_value`, the key now has the format `method|host|hash
Cache keys are used to store responses in storages, such as filesystem storage, which will use the cache key to create a file with that value.
You can write your own cache key implementation to have more meaningful file names and simplify cache monitoring.

=== "Before"

```
📁 root
└─╴📁 .cache
└─╴📁 hishel
└─╴📄 41ebb4dd16761e94e2ee36b71e0d916e
```

=== "After"

```
📁 root
└─╴📁 .cache
└─╴📁 hishel
└─╴📄 GET|hishel.com|41ebb4dd16761e94e2ee36b71e0d916e
```


15 changes: 15 additions & 0 deletions docs/advanced/storages.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ storage = hishel.FileStorage()
transport = hishel.CacheTransport(transport=httpx.HTTPTransport())
```

Here's how the filesystem storage looks:

```
📁 root
└─╴📁 .cache
└─╴📁 hishel
├─╴📄 GET|github.com|a9022e44881123781045f6fadf37a8b1
├─╴📄 GET|www.google.com|8bfc7fffcfd5f2b8e3485d0cc7450c98
├─╴📄 GET|www.python-httpx.org|5f004f4f08bd774c4bc4b270a0ca542e
└─╴📄 GET|hishel.com|41ebb4dd16761e94e2ee36b71e0d916e
```

!!! note
Note that by default, file names are just the hashed value, without the http method or hostname; to have meaningful names, see [custom cache keys](controllers.md#custom-cache-keys).

#### Storage directory

If the responses are saved in the filesystem, there should be a directory that contains our responses.
Expand Down

0 comments on commit 597a045

Please sign in to comment.