使用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是什么意思

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体数据为输入,我们将其重新表达成为一个标量场和一个辅助的引导向量场,用于编码肌肉纤维束的结构和走向...

在OpenGL和GLSL中进行点渲染(point rendering in openGL and GLSL)

我想你想要的是在启用GL_POINTS将粒子渲染为GL_POINTS ,然后使用片段着色器以常规方式映射纹理,或者在程序上生成晕圈渐变。 在GL_POINTS模式下渲染时,在顶点着色器中设置gl_PointSize以设置粒子的大小。 vec2变量gl_PointCoord将在片段着色器中为您提供片段的坐标。 编辑:设置gl_PointSize只有在启用了GL_PROGRAM_POINT_SIZE才会生效。 或者,只需使用glPointSize为所有点设置相同的大小。 此外,从OpenGL 3.2(...

如何在OpenGL中渲染叠加的平面对象?(How to render superimposed planar objects in OpenGL?)

来自片段着色器中每个纹理的样本可以完成您需要的任何组合,例如添加,但对于地理空间数据,它可能比这更复杂。 如果使用完成所有这些操作的库,则只需禁用深度测试,并渲染每个图层,调整传递之间的透明度函数。 Sample from each texture in your fragment shader doing whatever composing you need, such as additive, though for geospatial data its probably more comp...

如何从Vulkan渲染到OpenGL?(How to render to OpenGL from Vulkan?)

NVIDIA已经创建了OpenGL扩展NV_draw_vulkan_image,它可以在OpenGL中渲染VkImage 。 它甚至有一些与Vulkan信号灯等相互作用的机制。 但是, 根据文档 ,您必须绕过所有Vulkan图层,因为图层可以修改不可分派的句柄,而OpenGL扩展名不知道所述修改。 他们推荐的方法是将glGetVkProcAddrNV用于所有Vulkan函数。 这也意味着您无法访问任何依赖Vulkan图层的调试。 NVIDIA has created an OpenGL exten...

使用openGL渲染场景(Render a scene with openGL)

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_...

OpenGL / GLSL:从体积数据中渲染云/烟雾的最佳算法是什么?(OpenGL/GLSL: What is the best algorithm to render clouds/smoke out of volumetric data?)

我会首先尝试一个体积射线施法者。 您可以谷歌“使用光线投射进行体积可视化”,这应该可以为您提供所需的大部分内容。 NVidia通过3D纹理有一个很好的样本(使用openg)射线投射。 根据您的具体实施,您只需要逐步调整累积温度的体积,直到达到所需的密度。 如果您的音量不适合视频内存,您可以分片进行光线投射,然后执行合成步骤。 光线投射的快速描述: CPU:1)在世界空间中渲染六边形立方体,因为绘图原始确保使用深度剔除。 顶点着色器:2)在顶点着色器中存储顶点的世界位置(这将按每个fragmet进行...

使用OpenGL和GLSL的SSAO算法的奇怪表现行为(Strange performance behaviour with SSAO algorithm using OpenGL and GLSL)

简短的答案是缓存效率 。 为了理解这一点,让我们看看内部循环中的以下几行: 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...

在OpenGL中绘制两个点云之间的交点(Draw Intersection between two point clouds in OpenGL)

如果你想直观地合并它们,那么重叠的部分用红色和蓝色(紫色)混合着色你可以启用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 functio...

是否有可能破解GTK渲染到OpenGL纹理(Is it possible to hack GTK to render to OpenGL texture)

虽然这当然是可能的,但我会使用像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...

我想使用openStreetMap数据在openGL中渲染道路,我应该从哪里开始?(I want to use openStreetMap data to render roads in openGL, where should I start?)

为什么你认为你的方法很幼稚? 您可以让用户提供自行下载的XML文件,也可以使用API自行检索。 后一种方法允许您在用户平移地图时实施自动更新机制。 您可以使用Overpass API下载数据,而不是主API 。 它使用起来更快,更灵活,允许指定要下载的元素类型(例如,只有道路和建筑物)等等。 您已经提到过OSM2World ,请查看其免费提供的代码,以查看3D OpenGL渲染器的示例实现。 或者看看OSM的其他3D渲染器之一。 Why do you think your approach is ...

相关文章

更多

Redis Cookbook

Two years since its initial release, Redis already ...

Redis概述

什么是Redis Redis是Remote Dictionary Server的缩写, Redis是一 ...

redis 集群环境搭建-redis集群管理

集群架构 (1)所有的redis节点彼此互联(PING-PONG机制),内部使用二进制协议优化传输速度 ...

Redis 事务详解

Redis 事务可以一次执行多个命令, 并且带有以下两个重要的保证:事务是一个单独的隔离操作:事务中的 ...

redis sentinel.conf详解-redis集群管理

sentinel.conf详解 官方完整示例

redis安装-redis集群管理

安装redis [root@master opt]# mkdir /opt/redis [root ...

Redis 客户端连接、密码验证、连接数设置

Redis 通过监听一个 TCP 端口或者 Unix socket 的方式来接收来自客户端的连接,当一 ...

快速掌握 redis 数据类型

Redis支持以下五种数据类型 String(字符串) Hash(哈希表) List(列表) ...

Redis配置文件详解

redis是一款开源的、高性能的键-值存储(key-value store),和memcached类似 ...

基于linux下redis安装与配置

编译源程序:make install,复制可执行文件,Redis的启动,Redis随机启动

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本