public async Task GetCartAsync()

in src/cartservice/src/cartstore/ValkeyCartStore.cs [170:195]


    public async Task<Oteldemo.Cart> GetCartAsync(string userId)
    {
        _logger.LogInformation("GetCartAsync called with userId={userId}", userId);

        try
        {
            EnsureRedisConnected();

            var db = _redis.GetDatabase();

            // Access the cart from the cache
            var value = await db.HashGetAsync(userId, CartFieldName);

            if (!value.IsNull)
            {
                return Oteldemo.Cart.Parser.ParseFrom(value);
            }

            // We decided to return empty cart in cases when user wasn't in the cache before
            return new Oteldemo.Cart();
        }
        catch (Exception ex)
        {
            throw new RpcException(new Status(StatusCode.FailedPrecondition, $"Can't access cart storage. {ex}"));
        }
    }