首页 \ 问答 \ 如何在Jedis中使用SCAN命令(How to use SCAN commands in Jedis)

如何在Jedis中使用SCAN命令(How to use SCAN commands in Jedis)

我使用redis和jedis的时间已经很长一段时间了,从来没有需要SCAN命令。 但是现在我需要使用SCAN命令,特别是hscan。 我明白它在redis级别上的工作原理,但是jedis的Java包装方面让我感到困惑。 有ScanResultsScanParameter类流动,我没有清楚的如何正确使用它们的概念。 此功能的文档不存在或至少很难找到。 任何人都可以指出在哪里可以找到像使用hscan和jedis进行散列迭代的体面示例?

对不起,没有代码,但我迄今试过的只是没有任何意义。


I was using redis and jedis for quite some time and never needed the SCAN commands so far. Now however I need to use the SCAN commands, particularly hscan. I understand how it works on the redis level, but the jedis Java wrapper side is confusing to me. There are ScanResults and ScanParameter classes flowing around and I have no clear concept of how to use them properly. The documentation for this feature is non-existent or at least hard to find. Can anyone point out where to find decent examples of how to iterate over a hash using hscan with jedis?

Sorry to have no code, but what I tried so far just makes no sense whatsoever.


原文:https://stackoverflow.com/questions/33842026
更新时间:2023-08-03 17:08

最满意答案

PhoneGap Docs

指南针是一种传感器,用于检测设备指向的方向或方向。 它以从0到359.99的度数来衡量标题。

使用compassSuccess回调函数通过CompassHeading对象返回指南针标题信息。

function onSuccess(heading) {
    alert('Heading: ' + heading.magneticHeading);
};

function onError(error) {
    alert('CompassError: ' + error.code);
};

navigator.compass.getCurrentHeading(onSuccess, onError);

如果您想访问手机的x,y或z轴的旋转角度,您可以简单地使用裸机HTML5。 这里有一篇关于它的伟大文章: 这最后:使用设备方向

代码示例:

  window.addEventListener('deviceorientation', function(eventData) {
// gamma is the left-to-right tilt in degrees, where right is positive
var tiltLR = eventData.gamma;

// beta is the front-to-back tilt in degrees, where front is positive
var tiltFB = eventData.beta;

// alpha is the compass direction the device is facing in degrees
var dir = eventData.alpha

// deviceorientation does not provide this data
var motUD = null;

// call our orientation event handler
deviceOrientationHandler(tiltLR, tiltFB, dir, motUD);
}, false);

例


PhoneGap Docs

The compass is a sensor that detects the direction or heading that the device is pointed. It measures the heading in degrees from 0 to 359.99.

The compass heading information is returned via a CompassHeading object using the compassSuccess callback function.

function onSuccess(heading) {
    alert('Heading: ' + heading.magneticHeading);
};

function onError(error) {
    alert('CompassError: ' + error.code);
};

navigator.compass.getCurrentHeading(onSuccess, onError);

If you want to access the rotation-degrees of the x,y or z axis of the Phone you can simply use bare HTML5. Here is a great article about it: THIS END UP: USING DEVICE ORIENTATION

Code example:

  window.addEventListener('deviceorientation', function(eventData) {
// gamma is the left-to-right tilt in degrees, where right is positive
var tiltLR = eventData.gamma;

// beta is the front-to-back tilt in degrees, where front is positive
var tiltFB = eventData.beta;

// alpha is the compass direction the device is facing in degrees
var dir = eventData.alpha

// deviceorientation does not provide this data
var motUD = null;

// call our orientation event handler
deviceOrientationHandler(tiltLR, tiltFB, dir, motUD);
}, false);

example

相关问答

更多
  • PhoneGap Docs 指南针是一种传感器,用于检测设备指向的方向或方向。 它以从0到359.99的度数来衡量标题。 使用compassSuccess回调函数通过CompassHeading对象返回指南针标题信息。 function onSuccess(heading) { alert('Heading: ' + heading.magneticHeading); }; function onError(error) { alert('CompassError: ' + error.c ...
  • 不幸的是,你的问题不是特别简单。 我对Android API不太熟悉,如果你环顾四周,你会发现一些试图将重力加速度与外部设备加速度隔离开来的东西(我知道有一些传感器融合算法能够取得一定程度的成功) 。 问题的核心是由于重力引起的加速度和设备上的局部加速度是难以区分的(没有重力传感器这样的东西)。 加速度计只记录作用在设备上的总加速度,即所有加速度的总和。 隔离重力矢量并非易事,但我所看到的方法主要涉及使用陀螺仪,因为磁力计太简单并且包含太多的延迟。 相反,我建议您假设设备上的局部力可忽略不计,因此您的加速度 ...
  • 我只能确认问题。 作为稳定指南针应用的作者,我已经对不同设备的磁场传感器进行了多次测试。 我发现其中一台设备报告的mf绝对值约为其他不同设备在相同条件下报告的数量的2倍。 我在电话校准后做了很多测试,我甚至将设备置于“飞行模式”,试图最大限度地减少来自自身设备的电磁干扰。 另一个评论是,在某些设备上插入USB电缆会产生重要的磁场变化。 我在给定设备上看到的最糟糕的结果(在校准,飞行模式和USB断开之后)是这样的:在水平面上使用指南针应用设备,我读取一个读数,在水平面上旋转手机90度并采取一个新的指南针阅读。 ...
  • 传感器值始终相对于默认方向,因此您需要考虑远离默认方向的旋转。 为此,请使用以下内容: int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); float screen_adjustment = 0; switch(rotation) { case Surface.ROTATION_0: screen_adjustment = 0; break; case ...
  • 我刚尝试过,它工作正常。 一定要在XCode中设置正确的选项,如下所示: 在你这样做之前,你建立一个像这样的清晰项目 - > cordova create OrientationChange com.example.com OrientationChange cd OrientationChange cordova platform add ios cordova plugin add org.apache.cordova.console (您不需要这个用于方向更改,但它对调试很有用)。 cordova b ...
  • 如果您在将磁场X,Y,Z值从设备转换为全局参考系中时读取了我的答案您仍然无法理解它。 A1 。 将旋转矩阵与设备坐标系中磁场矢量的坐标相乘,得到世界坐标系中磁场矢量的坐标。 让我强调一下:上面说的旋转矩阵并没有反转旋转矩阵。 通过调用getRotationMatrix获得的旋转矩阵是基础矩阵从设备基础到世界基础的变化。 给出任何具有设备坐标系中坐标的矢量v,可以通过将旋转矩阵与设备系统坐标中的坐标相乘来获得相同矢量v的世界坐标系中的坐标。 反转矩阵是基础矩阵从世界基础到设备基础的变化。 因此,当您使用坐标多 ...
  • 好的,我终于设法让代码工作! 首先,我注册一个Sensor.TYPE_MAGNETIC_FIELD和Sensor.TYPE_GRAVITY :(就像Hoan Nguyen说的那样!) /** * Initialize the Sensors (Gravity and magnetic field, required as a compass * sensor) */ private void initSensors() { LocationManager locationManager = ...
  • 在你的评论中考虑你说它是你的指南针而不是你的代码,答案是重新校准你的指南针。 请参阅链接说明: http : //forum.xda-developers.com/showthread.php?t = 1778131 Considering in your comments you state it is your compass and not your code, the answer is to recalibrate your compass. Please see linked instructi ...
  • 您不需要Magnetic sensor进行pitch和roll 。 只需低通滤波器accelerometer即可获得重力。 private static final float ALPHA = 0.8; private float[] mGravity; public void onSensorChanged(SensorEvent event) { mGravity[0] = ALPHA * mGravity[0] + (1 - ALPHA) * event.values[0]; mGr ...
  • 最后,根据我自己的观察: 1)使用startDeviceMotionUpdatesUsingReferenceFrame:toQueue:withHandler: referenceFrame不等于allZeros或XArbitraryZVertical 。 2)将showsDeviceMovementDisplay设置为true 。 经过几次零值更新后,精确度CMMagneticFieldCalibrationAccuracyUncalibrated将进行标准化。 Finally, according t ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)