How to get byte[] data

Topics: Developer Forum
Feb 18, 2008 at 5:27 AM
I cached my byte[] data
byte[] data = LoadData();
IndexusDistributionCache.SharedCache.Add("test", data);

I want go get my data:
byte[] t = (byte[])IndexusDistributionCache.SharedCache.Get("test");
or
byte[] t = IndexusDistributionCache.SharedCache.Get<byte[]>("test");

But bouth of above were wrong.

Please tell me how do it ?
Feb 18, 2008 at 11:31 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 18, 2008 at 7:41 PM
The test application provides from version 2.0.0142 the test case 560 (this version is going to be available within the next few hours)

this option add and get serveral primitiv type also like byte[]

here the extract from the test application:
			Console.WriteLine();
			string dataToSend = "indeXus.Net Shared Cache as byte array";
			byte[] valueByteArray = System.Text.Encoding.UTF8.GetBytes(dataToSend);
			Console.WriteLine("Handling byte value ({0})", valueByteArray);
			Common.Util.CacheAdd(keyByteArray, valueByteArray);
			byte[] keyByteArrayValue = Common.Util.CacheGet<byte[]>(keyByteArray);
			if (keyByteArrayValue == null)
			{
				Console.WriteLine("could not read '{0}' from cache!!!!", valueByteArray);
			}
			else
			{
				Console.WriteLine("Sent and Received Data:\nS:'{0}'\nR:'{1}'", dataToSend, System.Text.Encoding.UTF8.GetString(keyByteArrayValue));
			}