hash

Redis基础

為{幸葍}努か 提交于 2019-12-22 10:52:35
Redis基础 1 概要 1.1 简介 1.2 特性 1.3 应用场景 1.4 启动、配置 1.5 全局指令 1.6 数据库管理 2 5种数据结构 2.1 字符串String类型 2.2 哈希Hash类型 2.3 列表List类型 2.4 集合Set 2.5 有序集合ZSet 3 使用场景 3.1 String应用 3.2 Set应用~用户标签、喜好、社交 3.2.1 用户标签 3.2.2 微信抽奖活动 3.2.3 朋友圈点赞 3.3 Hash应用 3.4 List应用 3.5 Zset应用 3.6 Hash与List应用~订单场景 4 使用String Hash 序列化三种方式存储用户信息比较 5 持久化机制 5.1 RDB 5.2 AOF 6 分布式锁 1 概要 1.1 简介 Redis 是使用 ANSI C 语言编写、支持网络、基于内存、可持久化的日志型、 Key-Value 数据库。 安装在磁盘 数据存储在内存 1.2 特性 速度快 键值对格式存储 功能丰富 简单稳定 持久化 主从复制 高可用分布式转移 客户端语言多 1.3 应用场景 缓存数据库 排行耪 计数器 社交网络 消息队列 1.4 启动、配置 1.5 全局指令 指令 说明 备注 keys * 查看所有键 dbsize 键总数 如果存在大量键,线上禁止使用 exists key 检查键是否存在 del key 删除键

Ruby Hash: creating a default value for non-existing elements

旧城冷巷雨未停 提交于 2019-12-22 10:52:21
问题 I learned from this answer here that this is possible: h = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) } h['bar'] # => {} h['tar']['star']['par'] # => {} Can someone explain how it works? 回答1: Hashes have a thing called a default_proc, which is simply a proc that Ruby runs when you try to access a hash key that doesn't exist. This proc receives both the hash itself and the target key as parameters. You can set a Hash's default_proc at any time. Passing a block parameter to Hash.new

redis

故事扮演 提交于 2019-12-22 10:51:58
高性能存储,数据都在内存中。所以高频的小数据都可以往里放等等。 数据类型分为list、set、zset、hash IOPS基本是HDD的上千倍 所有的操作都是原子的。单个操作是原子性的,多个操作也支持事务,即原子性 支持五种数据类型。string、hash、list、set、zset(有序集合) string set & get HASH(散列表) set & get & hmset 来源: CSDN 作者: CrankyPants 链接: https://blog.csdn.net/CrankyPants/article/details/103646412

Perl: Create a hash from an array

谁说胖子不能爱 提交于 2019-12-22 10:35:18
问题 If I have the following array my @header_line = ('id', 'name', 'age'); How do I create a hash from it equivalent to the line below? my %fields = { id => 0, name => 1, age => 2}; The reason I want to do this is so that I can use meaningful names rather than magic numbers for indexes. For example: $row->[$fields{age}]; # rather than $row->[2] 回答1: my %fields; @fields{@header_line} = (0 .. $#header_line); 回答2: my %fields = map { $header_line[$_] => $_ } 0..$#header_line; 回答3: You said in reply

How to calculate NTLM hash in python? [closed]

ぐ巨炮叔叔 提交于 2019-12-22 10:33:38
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . How can I calculate NTLM hash of a passowrd in python? Is there any library or sample code? I want it for writing a NTLM brute force tools with python (Like Cain & Abel ) 回答1: It is actually very quite simple use

Is there any way to use non-openssl md5 for hashlib in python?

老子叫甜甜 提交于 2019-12-22 10:27:08
问题 I generate md5 content hashes for upload verification, but it has recently come to my attention that this will fail for any users running on a FIPS enabled machine. FIPS disables openssl md5, resulting in a ValueError when I try to initialize hashlib. Normally I would use SHA instead, but I'm relying on an external service which requires a content-md5 header. My question is this: Is there any way to force Python to use a non-openssl hashing function? There was some talk here about adding a

BTree、B+Tree和HASH索引

落爺英雄遲暮 提交于 2019-12-22 10:08:13
  hash索引的特点是检索效率非常高,检索一次就可以定位,BTree需要从根节点往下查找,经过多次IO访问才能找到结果,所以hash索引的效率远高于BTree。 但hash自身也有很多局限与缺陷: 1.hash只能通过索引精准定位目标,而不能进行范围查询。 2.因为hash只保存了经过hash计算之后的hash值和对应的行指针,所以无法用于排序。 3.hash索引如果遇到大量hash值相等的情况,那么大量的记录指针信息会存于同一个hash值上,这样要定位一条记录时就会很麻烦,最终效率不一定会比BTree索引高。 4.对于组合索引,hash索引会把组合索引合并一起后再计算hash值,而不是各自单独计算hash值,所以通过组合索引前面几个索引键值时,hash索引无法使用。 5.因为不同索引键有可能存在相同的hash值,所以hash索引任何时候都不能避免全表扫描。 BTree又叫平衡多路查找树。一棵m阶的B 树 (m叉树)的特性如下: 1.树中每个结点最多含有m个孩子(m>=2); 2.除根结点和叶子结点外,其它每个结点至少有[ceil(m / 2)]个孩子(其中ceil(x)是一个取上限的函数); 3.若根结点不是叶子结点,则至少有2个孩子(特殊情况:没有孩子的根结点,即根结点为叶子结点,整棵树只有一个根节点); 4.所有叶子结点都出现在同一层,叶子结点不包含任何关键字信息 5.

Calculating Md5 Hash of Big Files

六月ゝ 毕业季﹏ 提交于 2019-12-22 09:41:50
问题 I want to make it very clear and simple. What if I have 1gb ram and I'm trying to calculate md5 hash of 2gb file? Currently, I'm doing it this way: private static string Md5Hash(byte[] input) { byte[] hash = MD5.Create().ComputeHash(input); StringBuilder builder = new StringBuilder(32); foreach(byte b in hash) { builder.Append(b.ToString("X2")); } return builder.ToString(); } // I'm using it like: 'Md5.AsString(File.ReadAllBytes(filePath))' So what are your suggestions? 回答1: Rather than

Set/Map实现

岁酱吖の 提交于 2019-12-22 09:35:52
HashSet public class HashSet < E > extends AbstractSet < E > implements Set < E > , Cloneable , java . io . Serializable HashSet源码: 常量: 第一个定义一个 HashMap,作为实现 HashSet 的数据结构;第二个 PRESENT 对象,因为前面讲过 HashMap 是作为键值对 key-value 进行存储的,而 HashSet 不是键值对,那么选择 HashMap 作为实现,其原理就是存储在 HashSet 中的数据 作为 Map 的 key,而 Map 的value 统一为 PRESENT HashSet 是哈希表实现的,HashSet中的数据是 无序 的,可以放入null,但 只能放入一个null ,两者中的值都不能重复,就如数据库中唯一约束。 HashSet要求放入的对象必须实现HashCode()方法,放入的对象**,是以hashcode码作为标识的**,而具有相同内容的 String对象,hashcode是一样,所以放入的内容不能重复。但是同一个类的对象可以放入不同的实例 。 SortedSet SortedSet继承自Set,他根据对象的比较顺序(可以是自然顺序,也可以是自定义的顺序),而不是插入顺序进行排序;

C# NTLM Hash Calculator

杀马特。学长 韩版系。学妹 提交于 2019-12-22 09:23:32
问题 I recently began learning C#. I tried to generate an NTLM hash in this language but I could't find a function to do this for me. In python 3.x I would import hashlib and calculate it with hashlib.new("md4", "Hello, World!".encode("utf-16le")) . I searched through the Object Browser in C# but didn't find anything, the closest was a windows NTLM authentication class. I also searched Microsoft's docs and found hash calculators, but only for sha1 and md5. Is there a way to calculate an NTLM hash