I am trying to connect to Amazon's Elastic Cache using .NET with the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Amazon.ElastiCacheCluster;
using Enyim.Caching;
using Enyim.Caching.Configuration;
using Enyim.Caching.Memcached;
namespace AmazonElasticCache
{
class Program
{
static void Main(string[] args)
{
ElastiCacheClusterConfig config = new ElastiCacheClusterConfig();
MemcachedClient memClient = new MemcachedClient(config);
// add data to the cluster
if (memClient.Store(StoreMode.Set, "key", "some data"))
{
Console.WriteLine("Successfully added data to cache.");
}
else
{
Console.WriteLine("Failed adding data to cache.");
}
var dataInStore = memClient.Get<string>("key");
if (dataInStore == "some data")
{
Console.WriteLine("Successfully read data from store.");
}
else
{
Console.WriteLine("Failed reading data from cache.");
}
if (memClient.Remove("key"))
{
Console.WriteLine("Successfully removed data from store.");
}
else
{
Console.WriteLine("Failed removing data from cache. ");
}
Console.WriteLine("Now adding a complex object");
// add data to the cluster
if (memClient.Store(StoreMode.Set, "key", new Itinerary()))
{
Console.WriteLine("Successfully added data to cache.");
}
else
{
Console.WriteLine("Failed adding data to cache.");
}
var itinerary = memClient.Get<Itinerary>("key");
if (itinerary != null)
{
Console.WriteLine("Successfully read data from store.");
}
else
{
Console.WriteLine("Failed reading data from cachee.");
}
if (memClient.Remove("key"))
{
Console.WriteLine("Successfully removed data from store.");
}
else
{
Console.WriteLine("Failed removing data from cache. ");
}
}
}
[Serializable]
public class Itinerary
{
public string Name { get; set; }
public string Id { get; set; }
public string[] SomeOtherStuff { get; set; }
}
}
With the following in app.config.
<configSections>
<section name="clusterclient" type="Amazon.ElastiCacheCluster.ClusterConfigSettings, Amazon.ElastiCacheCluster" />
</configSections>
<clusterclient>
<!-- the hostname and port values are from step 1 above -->
<endpoint hostname="my-cache-name.cfg.usw2.cache.amazonaws.com" port="11211" />
</clusterclient>
Console application does not crash, none of the actions work. I am running through all the failure paths. What am I missing?