# CacheGetAsAttempt

Get an item from the cache and return it as a Java {@link Optional}.

By default, the {@code cacheName} is set to {@code default}.

## Method Signature

```
CacheGetAsAttempt(id=[string], cacheName=[string])
```

### Arguments

| Argument    | Type     | Required | Description                                                         | Default   |
| ----------- | -------- | -------- | ------------------------------------------------------------------- | --------- |
| `id`        | `string` | `true`   | The cache id to retrieve                                            |           |
| `cacheName` | `string` | `false`  | The cache name to retrieve the id from, defaults to {@code default} | `default` |

## Examples

## Related

* [CacheClear](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cacheclear.md)
* [CacheCount](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachecount.md)
* [cacheDelete](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachedelete.md)
* [CacheGet](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cacheget.md)
* [CacheGetAll](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachegetall.md)
* [CacheGetAllIds](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachegetallids.md)
* [CacheGetDefaultCacheName](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachegetdefaultcachename.md)
* [CacheGetEngineProperties](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachegetengineproperties.md)
* [CacheGetMetadata](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachegetmetadata.md)
* [CacheGetOrFail](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachegetorfail.md)
* [CacheGetProperties](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachegetproperties.md)
* [CacheGetSession](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachegetsession.md)
* [CacheIdExists](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cacheidexists.md)
* [cacheKeyExists](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachekeyexists.md)
* [CachePut](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cacheput.md)
* [CacheRegionExists](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cacheregionexists.md)
* [CacheRegionNew](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cacheregionnew.md)
* [CacheRegionRemove](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cacheregionremove.md)
* [CacheRemove](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cacheremove.md)
* [CacheRemoveAll](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cacheremoveall.md)
* [CacheSetProperties](/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachesetproperties.md)


---

# 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://boxlang.ortusbooks.com/boxlang-framework/modularity/compat-cfml/reference/built-in-functions/cache/cachegetasattempt.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.
