# Caching

In order to provide eventual consistency to users' data, the **Email SDK** caches the results of each method call result from the Email Service. This allows the ability to provide your users with real-time synchronization of data updates with the service.

For optimal behavior, cached results are best used to serve offline/fast data to the user while performing a background sync/update to deliver new information to the user.

## Sudo CachePolicy

Some access APIs offer the ability to provide a `CachePolicy` property to determine the approach that is used to access the data. The two policies offered are `RemoteOnly` and `CacheOnly` .

### RemoteOnly

This policy will access the appropriate records directly from the Email Service. When used as the selected cache policy, this will add and refresh new and existing records to the cache, as well as return the latest data set.

### CacheOnly

This policy will not call out to the Email Service, but will instead use any existing cached result of previous API calls used with the `RemoteOnly` policy. This policy comes with a caveat; queried results are cached 'as called'. This means that a cached query will only match a direct query result to the service (using `RemoteOnly`). For instance, if a call is made to get all results using `RemoteOnly`, and then a filter call is applied using `CacheOnly`, all the same results from the previous call are returned.


---

# Agent Instructions: 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:

```
GET https://docs.sudoplatform.com/guides/email/caching-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
