# Local Cache

The Local Cache plugin provides an in-memory key-value cache within a Linx solution. Use it to avoid repeated calls to external systems — for example, caching settings or reference data that would otherwise require a database query on each use.

The plugin adds a **Cache** service to your solution. A solution may contain multiple Cache service instances; each operates independently with no shared state. Starting or stopping the service flushes all cached entries.

## Cache service properties

### Value type

The type of values stored in this cache. Accepts any built-in Linx type or a [custom type](/main-concepts/types.md#complex-types) defined in the solution. All entries in a cache share this type.

Defaults to `string`.

### Expiry

Seconds before a cached entry expires, measured from when the specific entry was set. `0` means entries do not expire.

Defaults to `0`.

{% hint style="info" %}
**Note**

Stopping and restarting a Cache service clears all entries. Use this as a deliberate flush mechanism.
{% endhint %}

{% hint style="warning" %}
**Warning**

Any service function called while the Cache service is not running will throw an exception.
{% endhint %}

## Service functions

* **TryGet**: Retrieves a value from the cache by key. Returns a result object with a `WasFound` flag and the cached `Value`.
* **Set**: Stores a value in the cache. Overwrites any existing entry with the same key.
* **Remove**: Removes a cached entry by key. No error is raised if the key does not exist.


---

# 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.linx.software/reference/plugins/localcache.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.
