首页 \ 问答 \ Jedis HMSET地图插入顺序(Jedis HMSET map insertion order)

Jedis HMSET地图插入顺序(Jedis HMSET map insertion order)

Jedis有一个hmset方法,允许您在特定键上设置字段及其值的映射。

我用这种方法:

Map<String, String> map = new LinkedHashMap<String, String>();

                // General player data
                map.put("name", player.getName());
                map.put("ip", player.getAddress().getAddress().getHostAddress());
                map.put("rank", "none");
                map.put("tokens", "0");
                map.put("coins", "0");

                // Arsenal player statistics
                map.put("ar_score", "0");
                map.put("ar_gameswon", "0");
                map.put("ar_gameslost", "0");
                map.put("ar_kills", "0");
                map.put("ar_deaths", "0");

                pipeline.hmset("uuid:" + uuid, map);

                pipeline.sync();
                core.redis.getJedisPool().returnResourceObject(jedis);

我决定使用LinkedHashMap来保留插入顺序 - 但是,在查看数据库时,它仍然会弄乱订单。

有没有人知道如何将其插入数据库而不会搞乱订单?

谢谢。


Jedis has a hmset method which allows you to set a map of fields and their values at a specific key.

I use the method this way:

Map<String, String> map = new LinkedHashMap<String, String>();

                // General player data
                map.put("name", player.getName());
                map.put("ip", player.getAddress().getAddress().getHostAddress());
                map.put("rank", "none");
                map.put("tokens", "0");
                map.put("coins", "0");

                // Arsenal player statistics
                map.put("ar_score", "0");
                map.put("ar_gameswon", "0");
                map.put("ar_gameslost", "0");
                map.put("ar_kills", "0");
                map.put("ar_deaths", "0");

                pipeline.hmset("uuid:" + uuid, map);

                pipeline.sync();
                core.redis.getJedisPool().returnResourceObject(jedis);

I decided to use a LinkedHashMap to retain the insertion order — however, when looking at the database, it still messes up the order.

Does anyone know how to insert it into the database without messing up the order?

Thank you.


原文:https://stackoverflow.com/questions/31767537
更新时间:2023-08-21 10:08

最满意答案

用方向指出你的意思并不完全清楚。 正如安东指出的那样,积分没有方向。 澄清你的问题将(希望)将其变成一个直接回答的问题。

一些建议:

  • 您以度为单位随机生成纬度和经度,然后转换为弧度。 只需生成0到2PI之间的随机数即可。

  • 跟踪您自己的Modelview矩阵。 那三个glRotatef调用可能不会做你想要的。 这需要一些线性代数专有技术,但完全值得。 您将拥有3D变换的直觉,它将使您的生活变得比处理OpenGL的“便利”方法容易得多。

  • 了解最新的OpenGL。 您使用的代码库已经被弃用了大约6年,并且已经被着色器编程取代了更长时间。


It's not entirely clear what you mean by points with direction. As Andon pointed out, points don't have direction. Clarifying your question will (hopefully) turn this into a directly answerable question.

Some suggestions:

  • You generate latitude and longitude randomly in degrees and then convert to radians. Just generate a random number between 0 and 2PI to begin with.

  • Keep track of your own Modelview matrix. Those three glRotatef calls are probably not going to do what you want. This requires some linear algebra know-how but is totally worth it. You will have an intuition for 3D transformations and it will make your life far easier than having to deal with OpenGL's "convenience" methods.

  • Learn up to date OpenGL. The codebase you're using has been deprecated for ~6 years and has been replaced by shader programming for even longer.

相关问答

更多
  • 这是图书馆不能将Raymenu改为垂直方向。 如果你想要垂直方向,你应该尝试这个库 。 Thats library cant change Raymenu into vertical direction. You should try this library if you want vertical direction.
  • 基本上,您希望将世界y轴与(单位长度)方向对齐。 为了用glRotatef组成旋转矩阵,你需要一个轴a = [a_x, a_y, a_z]和一个角度omega 。 将y取入d的旋转轴垂直于y和d ,因此可以通过矢量叉积来计算: a = cross(y, d); 旋转角度omega只是矢量y和d之间的角度,因此可以从点积计算: omega = acos(dot(y, d)); 现在您可以使用以下方法构建旋转矩阵: glRotatef(omega, a_x, a_y, a_z); 小心omega需要以度数 ...
  • 一种解决方案是添加一个int counter = 0; 您在游戏循环中更新(使用counter++; )每帧/时间步。 每次进行有效输入时设置为0并保存该输入。 概述代码: public class GameClassWhereUpdateIsDone { private enum Directions { None, Up, Down, Left, Right }; private int counter = 0; private Directions currentDirect ...
  • 通过在用户触摸开始时将速度设为0然后通过在触摸方向上施加脉冲来使其工作。 无论如何,谢谢你兄弟的帮助。 Made to to work by making velocity to 0 when user touches began and then by applying an impulse in the direction of touch. Anyways thank you bro for your help.
  • 您可以使用方法设置它: block.setTypeIdAndData(33, (byte)direction, false); 如果您想放置粘性活塞,请使用29作为第一个参数。 方向值如下: 0:向下 1:向上 2:北 3:南 4:西 5:东 对于最后一个参数, false表示禁用由块放置引起的不必要的块更新。 You can set it using method: block.setTypeIdAndData(33, (byte)direction, false); If you would lik ...
  • 用方向指出你的意思并不完全清楚。 正如安东指出的那样,积分没有方向。 澄清你的问题将(希望)将其变成一个直接回答的问题。 一些建议: 您以度为单位随机生成纬度和经度,然后转换为弧度。 只需生成0到2PI之间的随机数即可。 跟踪您自己的Modelview矩阵。 那三个glRotatef调用可能不会做你想要的。 这需要一些线性代数专有技术,但完全值得。 您将拥有3D变换的直觉,它将使您的生活变得比处理OpenGL的“便利”方法容易得多。 了解最新的OpenGL。 您使用的代码库已经被弃用了大约6年,并且已经被着 ...
  • 注意,在固定管道中,在调用glLightf(GL_POSITION)时,光的位置由矩阵堆栈的顶部变换。 因此,如果要在世界坐标中定义灯光的位置,则必须已将ViewProjection矩阵放在堆栈顶部。 这是一个常见的错误,许多人在设置相机/投影矩阵之前定义了灯在世界坐标中的位置,因此它实际上是在屏幕空间坐标中定义的。 the problem was that gles10 only does per-vertex-lighting. a per-pixel-lighting has to be implem ...
  • 好的我管理了一些东西 我占据了我的位置,固定位置和第三个位置,具有完全相同的经度和纬度90.我有两个向量一个指向北方,一个在直线上与我们的位置和固定位置。 我计算这些矢量之间的角度,并将此角度添加到旋转动画中。 我不认为我的解决方案是那么好,但因为我在论坛上没有找到任何其他内容我发布了答案^^。 Ok I managed something. I took my position, the fixed location and a third location with the exact same sam ...
  • 你不必为此使用glRotate。 你已经发现了一些你知道的东西,目标方向。 但目标方向并非全部,您仍然可以围绕目标轴旋转对象,因此您还需要向上向量。 这是对象的本地Z轴(或者您可能指定为“向前”的任何其他矩阵)。 您可以对此向量进行标准化,并将其放入对象变换矩阵的Z列中。 向上矢量必须垂直于目标轴。 要么你有一个,要么你从假设中推导出一个对象的向上向量应该至少向上,即有一个Y分量。 通过将矢量的标量积与目标轴相乘并从目标轴中减去目标轴矢量(由标量乘积缩放),然后进行归一化,可以得到向上并垂直于目标轴的矢量。 ...
  • 这一切都与你的渐变矢量有关。 这里: (0, 0, Color.RED, 1000, 1000, Color.BLUE)你的矢量是一个对角线矢量,起源于[0,0],然后结束或指向[ (0, 0, Color.RED, 1000, 1000, Color.BLUE) ]或在45度角。 将其改为直降:[0,0]到[0,1000]应该可以正常工作。 例如, new GradientPaint(0, 0, Color.RED, 0, 1000, Color.BLUE) It all has to do with ...

相关文章

更多

最新问答

更多
  • 获取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的基本操作命令。。。