在Booksleve中的Redis交易(Redis transactions in Booksleve)

下面的3个命令按原样执行时效果很好。

using (var redis = NewRedisConnection)
{
    await redis.Open();
    var allKeys = await redis.Keys.Find(db, "searchPattern");
    var allVals = await redis.Strings.GetString(db, allKeys);
    await redis.Keys.Remove(db, allKeys);

    //process the data I pull from redis
}

但是当我尝试将它们包装在一个事务中时它就会停止工作。 不抛出异常,但如果我调试执行似乎停止在var allKeys = ...我在设置事务时错过了什么?

using (var redis = NewRedisConnection)
{
    await redis.Open();
    var tran = redis.Createtransaction();

    var allKeys = await tran.Keys.Find(db, "searchPattern");
    var allVals = await tran.Strings.GetString(db, allKeys);
    await tran.Keys.Remove(db, allKeys);

    await tran.Execute();
    //process the data I pull from redis
}

The 3 commands below work perfectly when they are executed as is.

using (var redis = NewRedisConnection)
{
    await redis.Open();
    var allKeys = await redis.Keys.Find(db, "searchPattern");
    var allVals = await redis.Strings.GetString(db, allKeys);
    await redis.Keys.Remove(db, allKeys);

    //process the data I pull from redis
}

But when I try to wrap them in a transaction it stops working. Exceptions aren't thrown, but if I debug the execution seems to stop at var allKeys = ... Am I missing something While setting up the transaction?

using (var redis = NewRedisConnection)
{
    await redis.Open();
    var tran = redis.Createtransaction();

    var allKeys = await tran.Keys.Find(db, "searchPattern");
    var allVals = await tran.Strings.GetString(db, allKeys);
    await tran.Keys.Remove(db, allKeys);

    await tran.Execute();
    //process the data I pull from redis
}

原文:https://stackoverflow.com/questions/13435797
2022-09-01 14:09

满意答案

在初始化Nivo Slider之前添加此代码,并使用triangleNodePrev / Next替换参数。 这具有禁用链接上的默认操作的优点,因此,如果您使用href =“#”,则浏览器不会滚动回页面的顶部。

$('#previousButton, #nextButton').on('click', function (e) {

         // Prevent the link from being followed
         e.preventDefault();

         // Initialize variables 
         var buttonId = this.id,
          buttonClass = ('previousButton' == buttonId) ? '.nivo-prevNav' : '.nivo-nextNav';

         // Trigger the slider button
         $('.nivo-directionNav').find(buttonClass).click();
    });

Add this code before you initialize Nivo Slider and replace the parameters with your triangleNodePrev / Next. This has the advantage of disabling the default action on your links so that if you use href="#" the browser doesn't scroll back to the top of the page.

$('#previousButton, #nextButton').on('click', function (e) {

         // Prevent the link from being followed
         e.preventDefault();

         // Initialize variables 
         var buttonId = this.id,
          buttonClass = ('previousButton' == buttonId) ? '.nivo-prevNav' : '.nivo-nextNav';

         // Trigger the slider button
         $('.nivo-directionNav').find(buttonClass).click();
    });

相关问答

更多

IE中的Nivo滑块显示问题(Nivo Slider Display Problem in IE)

我相信IE的盒子模型会混淆Nivo代码。 添加这个CSS规则似乎解决了这个问题: #slider { height: 355px; } I believe something about IE's box model confuses the Nivo code. Adding this CSS rule seems to fix it: #slider { height: 355px; }

我的网站上的jQuery Nivo Slider有什么用?(What is up with jQuery Nivo Slider on my site?)

jQuery没有被加载到页面上。 这就是你试图加载它的方式: <script src=’https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js’ type="text/javascript"></script> Firebug显示这个URL是实际请求的内容: http://bikeshop.gostorego.com/%E2%80%99https://ajax.googleapis.com/ajax/libs/jquery...

Nivo滑块不居中(Nivo Slider is not centered)

你有两个选择...... a:执行软件的设计并使用图像的确切大小。 b:从滑块本身中删除边框样式和阴影,并将其应用于图像。 然后使用一些CSS样式来居中图像。 #slider img{ margin-left:0 auto; margin-right:0 auto; } 基本上,隐藏滑块div的所有痕迹,只是将图像居中。 这将是奇怪的,但如果那就是你想要的,那么你也会有更多的力量。 You have two options... a: Do what the software w...

悬停上的nivo滑块显示prev和下一个按钮(nivo slider on hover show prev and next buttons)

你可以使用一些CSS。 没有一些示例代码,我不知道具体的元素,但其实质是: <div class="parent"> <div> <!--STUFF--></div> <div class="navigation-links"><!--LINKS--></div> </div> 对于上面简单的标记,只需使用以下CSS: .parent .navigation-links { display:none; } .parent:hover .navigation-links { dis...

使用默认主题将图像置于Nivo Slider上?(Centering image on Nivo Slider using default theme?)

图像的位置正在JavaScript文件中加载。 编辑“jquery.nivo.slider.js”(请确保在标题中使用此文件而不是“jquery.nivo.slider.pack.js”。) 转到第85行: //Set first background slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); 找到上面的行。 将其更改为: //Set first backgro...

Nivo Slider(raphaeljs)的外部控件(Next / Prev)?(External Controls (Next / Prev) for Nivo Slider (raphaeljs)?)

在初始化Nivo Slider之前添加此代码,并使用triangleNodePrev / Next替换参数。 这具有禁用链接上的默认操作的优点,因此,如果您使用href =“#”,则浏览器不会滚动回页面的顶部。 $('#previousButton, #nextButton').on('click', function (e) { // Prevent the link from being followed e.preventDefault(); ...

nivo滑块,是一种总是显示下一个和prev箭头的方法吗?(nivo slider, is a way to always show the next and prev arrows?)

打开nivoslider js文件并找到 {A( “NIVO-directionNav”,F).hide(); f.hover(函数(){A( “NIVO-directionNav。”,F).show()},函数(){A(”。 NIVO-directionNav”,F).hide()} 改成 {A( “NIVO-directionNav”,F).show(); f.hover(函数(){A( “NIVO-directionNav。”,F).show()},函数(){A(”。 NIVO-direct...

如何使Nivo滑块响应(How to make Nivo Slider Responsive)

nivo滑块正式宣布响应,这是宣布。 http://nivo.dev7studios.com/2012/05/30/the-nivo-slider-is-responsive/ 演示: http://nivo.dev7studios.com/responsive-demo/ It was officially announced by nivo slider that it is responsive, Here is announcement. http://nivo.dev7studios.c...

使用Flash Builder创建像Nivo滑块一样的图像滑块(Create Image Slider Like Nivo Slider With Flash Builder)

使用计时器控件,并从xml文件加载图像,例如从xml Web服务加载它。 然后定义一个转换,每次加载新图像时都会触发转换。 当用户选择手动滚动图像时,请停止计时器。 只需单击Add Data菜单,然后选择XML(本地文件),然后按照向导进行操作。 样本: http : //forums.adobe.com/thread/502852 在加载的偶数加载的XML数据文件上,启动计时器,开始加载图像。 使用本教程作为示例定义过渡: http://hkcoding.wordpress.com/2011/0...

暂停Nivo滑块(Pause Nivo Slider)

我不知道您的确切代码,但您可以在其上使用.stop(),并在5秒后再次启动它。 。$( '#滑块')的数据( 'nivoslider')停止(); //停止Slider $('#slider')。data('nivoslider')。delay(5000).start(); //启动滑块 更正(因为延迟在这种情况下不起作用): $(window).load(function(){ $('#slider').nivoSlider({ animSpeed: 500, pauseTime...

相关文章

更多

Redis 事务详解

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

Redis概述

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

Redis Cookbook

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

redis安装-redis集群管理

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

Redis 哈希(Hash)详解

Redis hash 是一个string类型的field和value的映射表,hash特别适合用于存储 ...

基于linux下redis安装与配置

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

基于window安装redis

1、下载redis的window版本 下载地址: https://github.com/Service ...

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

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

redis 使用笔记01

今天和张哥商量 准备将微信服务端 移植到4joy服务器上。首先一个问题就是解决人员列表缓存同步问题。 ...

redis整合spring示例一

这里使用java操作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}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本