namespace FireflyClient
{
    public partial class FireflyClient
    {
        #region String Operations
        
        /// <summary>
        /// Sets a key-value pair
        /// </summary>
        public bool StringSet(string key, string value)
        {
            string response = ExecuteCommand("SET", key, value);
            return response.StartsWith("+OK");
        }
        
        /// <summary>
        /// Gets a value by key
        /// </summary>
        public string StringGet(string key)
        {
            string response = ExecuteCommand("GET", key);
            if (response.StartsWith('+'))
            {
                return response[1..].TrimEnd('\r', '\n');
            }
            return string.Empty;
        }
        
        /// <summary>
        /// Deletes a key from all stores (string, list, hash)
        /// </summary>
        public int Delete(string key)
        {
            string response = ExecuteCommand("DEL", key);
            if (response.StartsWith(':'))
            {
                if (int.TryParse(response[1..].TrimEnd('\r', '\n'), out int result))
                {
                    return result;
                }
            }
            return 0;
        }
        
        #endregion
    }
}