Exemple #1
0
        public byte[] Store(string commandName, string key, ulong flags, DateTime exptime, byte[] data)
        {
            if ((ulong)data.Length > _cache.Capacity)
            {
                return(Encoding.ASCII.GetBytes("ERROR Over capacity\r\n"));
            }
            bool stored = false;

            switch (commandName)
            {
            case "set":
                stored = _cache.Store(key, flags, data, exptime);
                break;

            case "replace":
                stored = _cache.Replace(key, flags, exptime, data);
                break;

            case "add":
                stored = _cache.Add(key, flags, exptime, data);
                break;

            case "append":
            case "prepend":
                stored = _cache.Append(key, flags, exptime, data, commandName == "append");
                break;
            }
            return(stored
                       ? Encoding.ASCII.GetBytes("STORED\r\n")
                       : Encoding.ASCII.GetBytes("NOT_STORED\r\n"));
        }