> For the complete documentation index, see [llms.txt](https://aptitude.gitbook.io/zaubercms/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aptitude.gitbook.io/zaubercms/extending-zaubercms/saving-custom-data.md).

# Saving Custom Data

When customizing the CMS there will come a point where you want to save some data that is not content or media and re-use it.

For this you can use GlobalData, which stores a string with an alias.&#x20;

```csharp
public class GlobalData
{
    public Guid Id { get; set; } = Guid.NewGuid().NewSequentialGuid();
    public string? Alias { get; set; }
    public string? Data { get; set; }
    public DateTime DateCreated { get; set; } = DateTime.UtcNow;
    public DateTime DateUpdated { get; set; } = DateTime.UtcNow;
}
```

You can save data into Global Data using the following method, you need to serialise your data into a string

```csharp
var saveResult = await Mediator.Send(new SaveGlobalDataCommand
{
    GlobalData = new GlobalData
    {
        Alias = "YourAlias",
        Data = "SerialisedData"
    }
});
```

Once it's saved it's very easy to get the data out by using this extension method

```csharp
var mydata= await Mediator.GetGlobalData<MyDataType>("YourAlias");
```

Global data is cached by default and auto flushed whenever `SaveGlobalDataCommand` is used. However, if you want to bypass the cache and manually call for the data you can use

```csharp
var globalData = await mediator.Send(new GetGlobalDataCommand
{
    Alias = "YourAlias", 
    Cached = false
});
```

{% hint style="info" %}
Did you know, we use Global Data to power the Global Settings in the CMS
{% endhint %}
