Search code examples
c#memcachedenyim.caching

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


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?


Solution

  • 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!