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

# Cache

The moss sdk provides a simple persistent cache that it will be internally used for example the scheduler.

When using the cache a `.cache` folder will be created. Every item of the cache will be represented by it's own file named by its key. The default cache serializes all items as the [cbor](https://de.wikipedia.org/wiki/Concise_Binary_Object_Representation) binary format. A class is cachable if it has an IShapable implementation. You can use the source generator of [PolyType](https://github.com/eiriktsarpalis/PolyType) by annoating your class with `[GenerateShape]`

## Working with the cache

The cache is accessible with `MossExtension.Instance.Cache` and has the following methods:

<pre class="language-csharp"><code class="lang-csharp">bool HasKey(string key)
void Set&#x3C;T>(string key, T value) // the value has to be an <a data-footnote-ref href="#user-content-fn-1">IShapable&#x3C;T></a>
T? Get&#x3C;T>(string key)
void Remove(string key)
</code></pre>

You can also implement your own cache by implementing the `ICache` interface.

[^1]: ```
    https://github.com/eiriktsarpalis/PolyType
    ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://furesoft.gitbook.io/moss.net.sdk/general/cache.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
