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