> For the complete documentation index, see [llms.txt](https://lesp.gitbook.io/lesp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lesp.gitbook.io/lesp/words/cache.md).

# Cache Manipulations

### Switching between cache files

Even if this sounds kind of hilarious, you can actually switch between cache files in LESP, basically by changing the `cache_file` parameter in the `Proofreader` class and then running the `load_cache` method. This is useful if you want to use different cache files for different wordlists. For example, you can use the cache file `lesp_cache/lesp.cache` for the wordlist `lesp-wordlist.txt` and the cache file `lesp_cache/lesp2.cache` for the wordlist `lesp-wordlist2.txt`, so that you won't get any compatibility issues.

```python
from lesp import Proofreader

# Create a Proofreader object with the default cache file
proofreader = Proofreader()

# Load the cache file for the wordlist "lesp-wordlist.txt"
proofreader.load_cache("lesp_cache/lesp2.cache")
```

That's it! Now the cache file `lesp_cache/lesp2.cache` will be used for the wordlist `lesp-wordlist.txt` instead of the default cache file `lesp_cache/lesp.cache`.

If you want to switch between cache files that will be used for `get_similar`, you can do so by changing the `cache_file` parameter in the `get_similar` method. For example, if you want to use the cache file `lesp_cache/lesp2.cache` for `get_similar` instead of the default cache file `lesp_cache/lesp.cache`, you can do so by running the following code:

```python
from lesp import Proofreader

# Create a Proofreader object with the default cache file
proofreader = Proofreader()

# Load the cache file for the wordlist "lesp-wordlist.txt"
proofreader.cache_file = "lesp_cache/lesp2.cache"

# Get similar words for the word "hello"
similar_words = proofreader.get_similar("helllllo")
```

### Modifying your cache

If you want to manually change something in your cache, you can do so by accessing the `cache` attribute of the `Proofreader` object. The `cache` attribute is a dictionary with the keys being the words and the values being the list of similar words. For example, if you want to set the cache for the word "hello" to `["hi", "hey", "hola"]`, you can do so by running the following code:

```python
from lesp import Proofreader

# Create a Proofreader object with the default cache file
proofreader = Proofreader()

# Load the cache file for the wordlist "lesp-wordlist.txt"
proofreader.load_cache("lesp_cache/lesp2.cache")

proofreader.cache_file = "lesp_cache/lesp2.cache"

# Set the cache for the word "hello"
proofreader.cache["hello"] = ["hi", "hey", "hola"]

# Save the cache
proofreader.save_cache()
```

### Clearing your cache

If you want to clear your cache, you can do so by running the `clear_cache` method of the `Proofreader` object. This will delete the cache file and the directory containing the cache file (if there is one).

```python
from lesp import Proofreader

# Create a Proofreader object with the default cache file
proofreader = Proofreader()

proofreader.cache_file = "lesp_cache/lesp2.cache"

# Load the cache file for the wordlist "lesp-wordlist.txt"
proofreader.load_cache("lesp_cache/lesp2.cache")

# Clear the cache
proofreader.clear_cache()
```
