首页 \ 问答 \ 保存redis哈希而不是字符串(Save redis hash instead of string)

保存redis哈希而不是字符串(Save redis hash instead of string)

我可以在redis中将字典保存为字符串,如下所示:

>>> r.set( 
           'rt.http://rottentomatoes.com/m/771354525/', 
           {"Director": "blasco ricardo", "Platform": "RT"}
         )

我如何将dict直接保存为dict / hash所以我不必使用json.loads将其读入dict? 目前,如果我执行r.get()我将dict作为字符串:

>>> r.get('rt.http://rottentomatoes.com/m/771354525/')
'{"Director": "blasco ricardo", "Platform": "RT"}'

I can save a dict as a string in redis as follows:

>>> r.set( 
           'rt.http://rottentomatoes.com/m/771354525/', 
           {"Director": "blasco ricardo", "Platform": "RT"}
         )

How would I save the dict as a dict/hash directly so I wouldn't have to use json.loads to read it into a dict? Currently, if I do r.get() I get the dict as a string:

>>> r.get('rt.http://rottentomatoes.com/m/771354525/')
'{"Director": "blasco ricardo", "Platform": "RT"}'

原文:https://stackoverflow.com/questions/29158838
更新时间:2022-04-30 10:04

最满意答案

经过一些研究,我终于拿到了B计划

我在另一个变量中写道:

$tracks = array();
        $tracks[] = array(
            'element' => 'cmi.core.lesson_status',
            'value' => 'completed'
        );

我跟着curl.php数组设置选项:

$arrayName = array('' => , );

然后当我插入scoid并尝试作为数组中的单个变量时:

$params = array('scoid' => '2', 'attempt' => '1', 'tracks' => $tracks);

和博拉!记录在我的桌子上:

插入记录


Well after some research I finally took plan B

I wrote tracks in a different variable:

$tracks = array();
        $tracks[] = array(
            'element' => 'cmi.core.lesson_status',
            'value' => 'completed'
        );

And I followed curl.php array set option:

$arrayName = array('' => , );

Then when I inserted scoid and attemps as single variables in the array:

$params = array('scoid' => '2', 'attempt' => '1', 'tracks' => $tracks);

and boala!the record is on my table:

Inserted record

相关问答

更多
  • 设置lesson_location相当于创建浏览器cookie ...您需要在课程中编写JavaScript来解析保存的字符串并使用它。 您需要在许多地方更改代码 - 您提供的代码是一个示例,它将您的课程设置为在其初始化的瞬间完成。 这不是你真正想要的。 这是关于开始课程和寻找书签的快速入门读物: var bookmark, initialized, status; var scorm = pipwerks.SCORM; //shortcut for easier typing function jump ...
  • 慢慢增长 - https://github.com/cybercussion/SCOBot 。 这更侧重于SCORM 2004 / 1.2协议的内容实施。 有一个Local_API_1484_11.js,意思是作为LMS Runtime的mimc。 这是轻量级的,并不像完整的实施那样强大,而是一开始。 我基于Claude Ostyn和无数其他在线资源(ADL,scorm.com等)的工作。 如果您与非营利/非商业项目有关联,请与我联系。 我有一个更完整的版本。 我还有一个书签,用于检查位于http://ww ...
  • 经过一些研究,我终于拿到了B计划 我在另一个变量中写道: $tracks = array(); $tracks[] = array( 'element' => 'cmi.core.lesson_status', 'value' => 'completed' ); 我跟着curl.php数组设置选项: $arrayName = array('' => , ); 然后当我插入scoid并尝试作为数组中的单个变量时: $param ...
  • 以下行返回什么? getValue("adl.nav.request_valid.choice.{target=page2}") What does the following line return? getValue("adl.nav.request_valid.choice.{target=page2}")
  • SCORM 2004还有一些额外功能,包括一些额外的跟踪字段以及排序和导航功能。 但是,发布到SCORM 2004的许多工具并没有实际利用这些功能,只是发送与SCORM 1.2相同的数据。 此外,内置于SCORM模块的Moodle仅支持SCORM 2004。 我的建议:除非你有特殊的理由使用SCORM 2004,否则使用SCORM 1.2。 There are a number of additional features of SCORM 2004 including some additional tr ...
  • 用PHP构建了一个SCORM播放器,这就是你需要的: a)导入器,它从imsmanifest.xml文件中读取XML,并在需要时在系统中创建表示。 此文件中最重要的是找到SCORM内容的“启动点” b)以javascript方式的SCORM引擎,它将与SCORM内容进行通信 c)数据库后端,用于存储需要存储的内容(基于规范) (b)上面是最重要和最困难的部分,但它也相对容易找到一个完整的开源代码(例如, efront包含一个实现,在www/js/LMSFuctions.php ) 说了这么多并且多年来一直支 ...
  • 所以没有跟踪,只是“播放内容”你基本上只是启动一个HTML文件。 任何SCORM CAM包通常都有一个imsmanifest.xml。 您需要能够解析它,然后生成一对多类型的目录,以呈现和播放您提到的内容。 您可以使用您提到的任何所需脚本语言执行该操作。 您找到的任何开源项目很可能都是非常陈旧或被遗弃,或者有太多的依赖性甚至无法理解。 您只想知道如何解析XML,构建TOC视图,以及如何在IFRAME,新窗口,弹出窗口或Tab中操作启动内容。 So with no tracking and just "pla ...
  • 为了保存针对API的数据集,您必须调用API.Commit('')或API.LMSCommit('')以保存学生尝试数据。 我会从那里开始。 提交数据可以通过导航按钮(如保存按钮)完成,但您也可以在终止SCO之前完成。 有些甚至在页面转弯或每2分钟自动保存。 I got the fix for the issues as per your guidance and did some R&D myself with code. 1) Updated few namespace and its values: ...
  • Pipwerks是伟大的,它没有任何问题。 你可能错过了这一点。 如果要将Web应用程序转换为scorm包,则需要: 1.添加一个imsmanifest.xml文件,该文件以scorm术语描述您的应用程序是什么以及它做了什么等。 2.通过JS与LMS进行通信(pipwerks将所有内容包装成方便的方法),以宣布用户已成功完成您的课程/使用过的app等。 3.将所有文件上传到LMS服务器,将LMS指向imsmanifest.xml并从那里启动。 Pipwerks is great and there's no ...
  • 不,Sakai没有配备SCORM播放器; 但是,有几个已经提供并正在使用中。 谷歌为Sakai SCORM找到它们。 我们与Sakai 10一起使用的是EDIA目前维护的那个 。 使用Sakai 11.x安装它很简单,如果您已经从源代码构建Sakai:从GitHub检查其源代码,切换到正确的分支,在Sakai的主pom.xml添加一行以指向它,然后重新编译Sakai - 有关详细信息,请参阅安装说明 。 我们有一个权限问题:只有admin能够安装SCORM包,这似乎是由于一个错误。 No, Sakai do ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。