Sharepoint - Using Distributed Cache programmatically. "Cache referred to does not exist" error

This is how the internal implementation of GetDefaultCache method looks like:

public DataCache GetDefaultCache()
{
  string cacheName = "default";
  return this.GetCache(cacheName);
}

It's just trying to call GetCache("defaul"). 'default' cache just does not exist. The real name of the default cache should look more like:

DistributedDefaultCache_bbc9d9fe-ea79-477a-890c-867b1ae0c91b

This GUID turns out to be a farm ID.

So, this is an example that works:

    static void Main(string[] args)
    {
        List<DataCacheServerEndpoint> servers = new List<DataCacheServerEndpoint>();
        servers.Add(new DataCacheServerEndpoint("server.domain", 22233));
        DataCacheFactoryConfiguration configuration = new DataCacheFactoryConfiguration();
        configuration.ChannelOpenTimeout = TimeSpan.FromSeconds(120);
        configuration.IsCompressionEnabled = false;
        configuration.MaxConnectionsToServer = 10;
        configuration.RequestTimeout = TimeSpan.FromSeconds(120);
        configuration.Servers = servers;
        configuration.TransportProperties.MaxBufferSize = 1000000;
        DataCacheFactory dataCacheFactory = new DataCacheFactory(configuration);
        DataCache cache = dataCacheFactory.GetCache("DistributedDefaultCache_" + SPFarm.Local.Id);

        if (cache.Get("MyKEY") == null)
        {
            cache.Add("MyKEY", DateTime.Now);
        }
        DateTime dt = (DateTime)cache.Get("MyKEY");
        Console.WriteLine(dt);
    }

Important Update

I've found that you can't use default App Fabric cluster that is installed with prerequisites. Looks like it's unsupported by Microsoft.

Do not use the AppFabric cache cluster supporting your SharePoint Server 2013 farm. Run your separate AppFabric cache cluster for your custom applications on separate servers from the servers dedicated to your SharePoint Server 2013 farm.

What a shame!