How do I append data to memcached using Enyim.Caching in C#?

236 Views Asked by At

I am trying to append data to memcached using C# Enyim.Caching but it forces me to send data as ArraySegment

public bool Append(string key, ArraySegment<byte> data);

How do I convert a string or array of strings to ArraySegment ?

Is there a better way to use Append?

1

There are 1 best solutions below

1
On BEST ANSWER

I was able to find out how to do this. In order to convert a string to ArraySegment<byte> use the following code.

byte[] arrByte = Encoding.ASCII.GetBytes(data);
ArraySegment<byte> data = new ArraySegment<byte>(arrByte, 0, arrByte.Length);

Hope this helps someone!