如何在Mojo :: Redis2中保存哈希值?(How to save hash value in Mojo::Redis2?)
我想在Mojo :: Redis2中保存哈希值。 示例哈希值如下所示。
'user' => { 'manage-detail' => { '46' => 'edit', '45' => 'list', '44' => 'create', '48' => 'delete', '47' => 'search' }, 'manage-procedure' => { '27' => 'search', '25' => 'list', '24' => 'create', '26' => 'edit' } }
我使用下面的代码保存并从redis读取。
$self->app->redis->hset('test', %HoH); my %res = $self->app->redis->hget("test",'user');
但它没有用。 读取哈希值时为空。
I am trying to save hash value in Mojo::Redis2. The sample hash value is given below.
'user' => { 'manage-detail' => { '46' => 'edit', '45' => 'list', '44' => 'create', '48' => 'delete', '47' => 'search' }, 'manage-procedure' => { '27' => 'search', '25' => 'list', '24' => 'create', '26' => 'edit' } }
I am saving and reading from redis using the code below.
$self->app->redis->hset('test', %HoH); my %res = $self->app->redis->hget("test",'user');
But it is not working. When reading the hash value is empty.
原文:https://stackoverflow.com/questions/50113851
更新时间:2023-07-02 09:07
最满意答案
opt => opt.MapFrom(src => src.FacebookUser == null ? 0 : src.FacebookUser.FacebookUniqueId)
哎呀,如果我刚刚检查过第一个想法是否奏效,我认为
MapFrom
方法只用一个表达式指向一个属性来解决这个问题......opt => opt.MapFrom(src => src.FacebookUser == null ? 0 : src.FacebookUser.FacebookUniqueId)
Yikes, if I had just checked if the first idea worked, thought the
MapFrom
method only took an expression that pointed to a property to resolve it that way...
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
AutoMapper:如果source == null,则创建目标类型的实例(AutoMapper: create instance of destination type if source == null)[2021-12-30]
回答我自己的问题(部分): AutoMapper具有一个名为AllowNullDestinationValues的配置属性,默认情况下它被设置为true 。 通过将其设置为false ,我会得到问题中显示的行为,例如: Mapper.Configuration.AllowNullDestinationValues = false; //... Source source = null; Dest d = AutoMapper.Mapper.Map -
AutoMapper - 如何映射到嵌套类型的值 - 可能为空?(AutoMapper - How to map to a value in a nested type - which could be null?)[2022-05-06]
opt => opt.MapFrom(src => src.FacebookUser == null ? 0 : src.FacebookUser.FacebookUniqueId) 哎呀,如果我刚刚检查过第一个想法是否奏效,我认为MapFrom方法只用一个表达式指向一个属性来解决这个问题...... opt => opt.MapFrom(src => src.FacebookUser == null ? 0 : src.FacebookUser.FacebookUniqueId) Yikes, if ... -
AutoMapper空源值和自定义类型转换器,无法映射?(AutoMapper null source value and custom type converter, fails to map?)[2022-07-26]
快速查看一下automapper的源代码,Mapper.Map(对象源)进行空检查。 如果source为null,则返回默认值T: public TDestination Map(object source, Action opts) { var mappedObject = default(TDestination); if (source != null) { ... -
以下是使用自定义类型转换器执行此操作的一种方法: public class IDestConverter : TypeConverter
-
您是否尝试过使用此处建议的opt.Skip。 Mapper.CreateMap
() .ForMember(s => s.S, opt => opt.Skip(src => !string.IsNullOrWhiteSpace(src.S))); 编辑: 经过一些挖掘源头。 我在TypeMapObjectMapperRegistry类(处理嵌套对象的映射的类)中看到它返回,然后查看是否需要保留目标值(使用UseDestinationValue)。 否则,我会建议: Ma ... -
您需要为所有嵌套类创建显式映射: cfg.CreateMap
(); opts => opts.MapFrom()用于源和目标中的成员名称不匹配时,它不会在这些类型之间注册映射。 So finally I figured out what was wrong. MoneyItemBase is abstract and abstract classes cannot be instantiated ... -
如何使用AutoMapper将空值映射到特定的映射?(How to map null values with AutoMapper for an specific mapping?)[2022-02-16]
找到了解决方案: Mapper.Initialize( Conf => { Conf.ForSourceType().AllowNullDestinationValues = true; } ); 多谢你们 : ) 照顾你的目的地字段类型(记住你需要可以为空的类型。例如'Byte?') Found a solution: Mapper.Initialize( Conf => { Conf.ForSourceType 首先,Automapper支持集合的映射。 您不需要在循环中映射每个项目。 其次 - 每次需要映射单个对象时,无需重新创建映射。 将映射创建放到应用程序启动代码中(或在首次使用映射之前)。 最后 - 使用Automapper,您可以创建映射并定义如何为某些属性执行自定义映射: Mapper.CreateMap() .ForMember(pts => pts.PropertyName, opt => opt.MapFrom( ... 相关文章
更多- Redis 哈希(Hash)详解
- Redis概述
- 一致性hash和solr千万级数据分布式搜索引擎中的应用
- 一致性hash和solr千万级数据分布式搜索引擎中的应用
- 一致性hash和solr千万级数据分布式搜索引擎中的应用
- Redis配置文件详解
- 快速掌握 redis 数据类型
- 把一个对象数组映射成hash?
- redis 集群环境搭建-redis集群管理
- rails save问题数据库表主键必须是id吗?
最新问答
更多- 获取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的基本操作命令。。。