首页 \ 问答 \ 使用StackExchange.Redis连接到redis失败后,事务无法正常工作(Transaction not working after unsuccessful connection to redis using StackExchange.Redis)

使用StackExchange.Redis连接到redis失败后,事务无法正常工作(Transaction not working after unsuccessful connection to redis using StackExchange.Redis)

我不确定,这是一个错误还是我做错了什么。 代码如下:

        using StackExchange.Redis;

        ConnectionMultiplexer conn = null;
        while (conn == null);
        {
            try
            {
                conn = ConnectionMultiplexer.Connect("localhost:6379");
            }
            catch (Exception)
            {
                conn = null;
                Thread.Sleep(TimeSpan.FromSeconds(5));
            }
        }

        var db = conn.GetDatabase();
        var transaction = db.CreateTransaction();

        var tasks = new List<Task>();
        tasks.Add(transaction.HashSetAsync("key", "field", "value"));
        if (transaction.Execute())
        {
            Task.WaitAll(tasks.ToArray());
        }

当我使用启动redis(Windows版本 - 2.6,2.8.17,2.8.19)运行它时,一切正常。 如果我在循环的几个循环之后启动redis,要么它不会跳转到if语句,要么跳转并在WaitAll()上被阻塞。 如果我尝试检查redis中的值,则会存储它们。

当我们启动服务器并忘记启动redis时会发生这种情况。 在推迟redis的开始后,它会被卡住。 使用批处理而不是事务时会出现同样的问题。

我与多路复用器连接错误还是错误? (我发现很少看起来很相似,但我不确定)


I'm not sure, whether it is a bug or I'm doing something wrong. Here is the code:

        using StackExchange.Redis;

        ConnectionMultiplexer conn = null;
        while (conn == null);
        {
            try
            {
                conn = ConnectionMultiplexer.Connect("localhost:6379");
            }
            catch (Exception)
            {
                conn = null;
                Thread.Sleep(TimeSpan.FromSeconds(5));
            }
        }

        var db = conn.GetDatabase();
        var transaction = db.CreateTransaction();

        var tasks = new List<Task>();
        tasks.Add(transaction.HashSetAsync("key", "field", "value"));
        if (transaction.Execute())
        {
            Task.WaitAll(tasks.ToArray());
        }

When I run it with started redis (windows version - 2.6, 2.8.17, 2.8.19), everything works fine. If I start redis after few loops of the cycle, either it doesn't jump into if-statement or it jumps and get blocked on WaitAll(). If I try to check values in redis, they are stored.

This situation happens when we start server and forget to start redis. After postpone start of redis it gets stuck. The same problem appears when using batch instead of transaction.

Am I doing connection to multiplexer wrong or is it bug? (I found few that looked similar but I'm not sure)


原文:https://stackoverflow.com/questions/29851293
更新时间:2022-05-08 14:05

最满意答案

我会首先尝试一个体积射线施法者。

您可以谷歌“使用光线投射进行体积可视化”,这应该可以为您提供所需的大部分内容。 NVidia通过3D纹理有一个很好的样本(使用openg)射线投射。

根据您的具体实施,您只需要逐步调整累积温度的体积,直到达到所需的密度。

如果您的音量不适合视频内存,您​​可以分片进行光线投射,然后执行合成步骤。

光线投射的快速描述:

CPU:1)在世界空间中渲染六边形立方体,因为绘图原始确保使用深度剔除。

顶点着色器:2)在顶点着色器中存储顶点的世界位置(这将按每个fragmet进行插值)

片段着色器:3)使用插值位置减去摄像机位置来获得遍历音量的矢量。 4)使用while循环从立方体上的点穿过另一侧的音量。 有3种方法可以知道何时结束。 A)在每个步骤测试该点是否仍在立方体中。 B)与立方体进行光线交叉并计算交叉点之间的距离。 C)使用正面剔除对立方体进行预渲染,并将深度存储到第二个纹理贴图中,然后在屏幕像素处进行采样以获得距离。

5)循环时累积并设置像素颜色。


I would try a volume ray caster first.

You can google "Volume Visualization With Ray Casting" and that should give you most of what you need. NVidia has a great sample (using openg) of ray casting through a 3D texture.

On your specific implementation, you would just need to keep stepping through the volume accumlating the temperature until you reach the wanted density.

If your volume doesn't fit in video memory, you can do the ray casting in pieces and then do a composition step.

A quick description of ray casting:

CPU: 1) Render a six sided cube in world space as the drawing primitive make sure to use depth culling.

Vertex shader: 2) In the vertex shader store off the world position of the vertices (this will interpolate per fragmet)

Fragment shader: 3) Use the interpolated position minus the camera position to get the vector of traversal through the volume. 4) Use a while loop to step through the volume from the point on the cube through the other side. 3 ways to know when to end. A) at each step test if the point is still in the cube. B) do a ray intersection with cube and calculate the distance between the intersections. C) do a prerender of the cube with forward face culling and store the depths into a second texture map then just sampe at the screen pixel to get the distance.

5) accumulate while you loop and set the pixel color.

相关问答

更多
  • volumetric scalar data 体积标量数据 双语例句 1 To represent the structure and orientation of muscle bundles, we reformulate the volumetric DTI data into a scalar field and an auxiliary guidance vector field. 以DTI体数据为输入,我们将其重新表达成为一个标量场和一个辅助的引导向量场,用于编码肌肉纤维束的结构和走向。
  • 我想你想要的是在启用GL_POINTS将粒子渲染为GL_POINTS ,然后使用片段着色器以常规方式映射纹理,或者在程序上生成晕圈渐变。 在GL_POINTS模式下渲染时,在顶点着色器中设置gl_PointSize以设置粒子的大小。 vec2变量gl_PointCoord将在片段着色器中为您提供片段的坐标。 编辑:设置gl_PointSize只有在启用了GL_PROGRAM_POINT_SIZE才会生效。 或者,只需使用glPointSize为所有点设置相同的大小。 此外,从OpenGL 3.2(核心)开始 ...
  • 来自片段着色器中每个纹理的样本可以完成您需要的任何组合,例如添加,但对于地理空间数据,它可能比这更复杂。 如果使用完成所有这些操作的库,则只需禁用深度测试,并渲染每个图层,调整传递之间的透明度函数。 Sample from each texture in your fragment shader doing whatever composing you need, such as additive, though for geospatial data its probably more complex t ...
  • NVIDIA已经创建了OpenGL扩展NV_draw_vulkan_image,它可以在OpenGL中渲染VkImage 。 它甚至有一些与Vulkan信号灯等相互作用的机制。 但是, 根据文档 ,您必须绕过所有Vulkan图层,因为图层可以修改不可分派的句柄,而OpenGL扩展名不知道所述修改。 他们推荐的方法是将glGetVkProcAddrNV用于所有Vulkan函数。 这也意味着您无法访问任何依赖Vulkan图层的调试。 NVIDIA has created an OpenGL extension, ...
  • glDrawElements(GL_TRIANGLES, mesh->pos.size(), GL_UNSIGNED_INT, mesh->triangle.data()); glDrawElements(GL_QUADS, mesh->quad.size(), GL_UNSIGNED_INT, mesh->quad.data()); 看看两个电话的第二个参数。 四边形不正确。 glVertexAttribPointer(vertex_pos_loc, mesh->pos.size(), GL_FLOAT ...
  • 我会首先尝试一个体积射线施法者。 您可以谷歌“使用光线投射进行体积可视化”,这应该可以为您提供所需的大部分内容。 NVidia通过3D纹理有一个很好的样本(使用openg)射线投射。 根据您的具体实施,您只需要逐步调整累积温度的体积,直到达到所需的密度。 如果您的音量不适合视频内存,您可以分片进行光线投射,然后执行合成步骤。 光线投射的快速描述: CPU:1)在世界空间中渲染六边形立方体,因为绘图原始确保使用深度剔除。 顶点着色器:2)在顶点着色器中存储顶点的世界位置(这将按每个fragmet进行插值) 片 ...
  • 简短的答案是缓存效率 。 为了理解这一点,让我们看看内部循环中的以下几行: vec4 Sample_VS = vec4(Origin_VS + OrientMatrix * SSAOKernel[idx], 1.0f); //Sample translated in view space vec4 Sample_HS = ProjMatrix * Sample_VS; //Sample in homogeneus space vec3 Sample_CS = Sample_HS.x ...
  • 如果你想直观地合并它们,那么重叠的部分用红色和蓝色(紫色)混合着色你可以启用alpha混合并使用适当的混合功能。 请参阅此处获取一些提示。 If you want to merge them just visually, so the overlapping parts are colored with a mix of red and blue (purple) you can enable alpha blending and use the appropriate blend functions. S ...
  • 虽然这当然是可能的,但我会使用像Clutter这样的真正的OpenGL小部件工具箱。 如果你想用OpenGL渲染GTK +,我首先创建一个新的GDK后端(X11 / OpenGL或类似的东西),然后(重新)使用OpenGL实现所有GDK绘图函数。 一个好的副作用是,所有的GTK +窗口都允许普通的OpenGL渲染,也就是说,不再需要GtkGLWidget类。 While this is certainly possible, I'd instead use a real OpenGL widget tool ...
  • 为什么你认为你的方法很幼稚? 您可以让用户提供自行下载的XML文件,也可以使用API自行检索。 后一种方法允许您在用户平移地图时实施自动更新机制。 您可以使用Overpass API下载数据,而不是主API 。 它使用起来更快,更灵活,允许指定要下载的元素类型(例如,只有道路和建筑物)等等。 您已经提到过OSM2World ,请查看其免费提供的代码,以查看3D OpenGL渲染器的示例实现。 或者看看OSM的其他3D渲染器之一。 Why do you think your approach is naive ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)