Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
thibaultcha
lua-resty-jit-uuid
提交
3a2fae8b
L
lua-resty-jit-uuid
项目概览
镜像
/
thibaultcha
/
lua-resty-jit-uuid
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
lua-resty-jit-uuid
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3a2fae8b
编写于
5月 09, 2016
作者:
T
Thibault Charbonnier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
doc(ldoc) 0.0.4 documentation (v5 UUIDs)
上级
02e2866b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
113 addition
and
10 deletion
+113
-10
doc/index.html
doc/index.html
+110
-5
lib/resty/jit-uuid.lua
lib/resty/jit-uuid.lua
+3
-5
未找到文件。
doc/index.html
浏览文件 @
3a2fae8b
...
...
@@ -50,7 +50,7 @@
</p>
<h3>
Info:
</h3>
<ul>
<li><strong>
Release
</strong>
: 0.0.
3
</li>
<li><strong>
Release
</strong>
: 0.0.
4
</li>
<li><strong>
License
</strong>
: MIT
</li>
<li><strong>
Author
</strong>
: Thibault Charbonnier
</li>
</ul>
...
...
@@ -72,12 +72,20 @@
</tr>
<tr>
<td
class=
"name"
nowrap
><a
href=
"#factory_v3"
>
factory_v3 (namespace)
</a></td>
<td
class=
"summary"
>
Generate a v3 UUID factory.
</td>
<td
class=
"summary"
>
Instanciate a v3 UUID factory.
</td>
</tr>
<tr>
<td
class=
"name"
nowrap
><a
href=
"#factory_v5"
>
factory_v5 (namespace)
</a></td>
<td
class=
"summary"
>
Instanciate a v5 UUID factory.
</td>
</tr>
<tr>
<td
class=
"name"
nowrap
><a
href=
"#generate_v3"
>
generate_v3 (namespace, name)
</a></td>
<td
class=
"summary"
>
Generate a v3 UUID.
</td>
</tr>
<tr>
<td
class=
"name"
nowrap
><a
href=
"#generate_v5"
>
generate_v5 (namespace, name)
</a></td>
<td
class=
"summary"
>
Generate a v5 UUID.
</td>
</tr>
</table>
<br/>
...
...
@@ -198,7 +206,7 @@
<strong>
factory_v3 (namespace)
</strong>
</dt>
<dd>
Gener
ate a v3 UUID factory.
Instanci
ate a v3 UUID factory.
<h3>
Parameters:
</h3>
...
...
@@ -235,6 +243,49 @@
---
>
e8d3eeba-
<span
class=
"number"
>
7723
</span>
-
<span
class=
"number"
>
3
</span>
b72-bbc5-
<span
class=
"number"
>
8
</span>
f598afa6773
</pre>
</ul>
</dd>
<dt>
<a
name =
"factory_v5"
></a>
<strong>
factory_v5 (namespace)
</strong>
</dt>
<dd>
Instanciate a v5 UUID factory.
<h3>
Parameters:
</h3>
<ul>
<li><span
class=
"parameter"
>
namespace
</span>
<span
class=
"types"
><a
class=
"type"
href=
"http://www.lua.org/manual/5.1/manual.html#5.4"
>
string
</a></span>
(must be a valid UUID according to
<a
href=
"index.html#is_valid"
>
is_valid
</a>
)
</li>
</ul>
<h3>
Returns:
</h3>
<ol>
<li>
<span
class=
"types"
><span
class=
"type"
>
function
</span></span>
<code>
factory
</code>
: a v5 UUID generator.
</li>
<li>
<span
class=
"types"
><a
class=
"type"
href=
"http://www.lua.org/manual/5.1/manual.html#5.4"
>
string
</a></span>
<code>
err
</code>
: a string describing an error
</li>
</ol>
<h3>
Usage:
</h3>
<ul>
<pre
class=
"example"
>
<span
class=
"keyword"
>
local
</span>
uuid =
<span
class=
"global"
>
require
</span>
<span
class=
"string"
>
'resty.jit-uuid'
</span>
<span
class=
"keyword"
>
local
</span>
fact =
<span
class=
"global"
>
assert
</span>
(uuid.factory_v5(
<span
class=
"string"
>
'e6ebd542-06ae-11e6-8e82-bba81706b27d'
</span>
))
<span
class=
"keyword"
>
local
</span>
u1 = fact(
<span
class=
"string"
>
'hello'
</span>
)
<span
class=
"comment"
>
---
>
4850816f-1658-5890-8bfd-1ed14251f1f0
</span>
<span
class=
"keyword"
>
local
</span>
u2 = fact(
<span
class=
"string"
>
'foobar'
</span>
)
---
>
c9be99fc-
<span
class=
"number"
>
326
</span>
b-
<span
class=
"number"
>
5066
</span>
-bdba-dcd31a6d01ab
</pre>
</ul>
</dd>
<dt>
<a
name =
"generate_v3"
></a>
...
...
@@ -244,7 +295,8 @@
Generate a v3 UUID.
v3 UUIDs are created from a namespace and a name (a UUID and a string).
The same name and namespace result in the same UUID. The same name and
different namespaces result in different UUIDs, and vice-versa.
</p>
different namespaces result in different UUIDs, and vice-versa.
The resulting UUID is derived using MD5 hashing.
</p>
<p>
This is a sugar function which instanciates a short-lived v3 UUID factory.
It is an expensive operation, and intensive generation using the same
...
...
@@ -287,6 +339,59 @@
---
>
<span
class=
"number"
>
3
</span>
db7a435-
<span
class=
"number"
>
8
</span>
c56-
<span
class=
"number"
>
359
</span>
d-a563-
<span
class=
"number"
>
1
</span>
b69e6802c78
</pre>
</ul>
</dd>
<dt>
<a
name =
"generate_v5"
></a>
<strong>
generate_v5 (namespace, name)
</strong>
</dt>
<dd>
Generate a v5 UUID.
v5 UUIDs are created from a namespace and a name (a UUID and a string).
The same name and namespace result in the same UUID. The same name and
different namespaces result in different UUIDs, and vice-versa.
The resulting UUID is derived using SHA-1 hashing.
</p>
<p>
This is a sugar function which instanciates a short-lived v5 UUID factory.
It is an expensive operation, and intensive generation using the same
namespaces should prefer allocating their own long-lived factory with
<a
href=
"index.html#factory_v5"
>
factory_v5
</a>
.
<h3>
Parameters:
</h3>
<ul>
<li><span
class=
"parameter"
>
namespace
</span>
<span
class=
"types"
><a
class=
"type"
href=
"http://www.lua.org/manual/5.1/manual.html#5.4"
>
string
</a></span>
(must be a valid UUID according to
<a
href=
"index.html#is_valid"
>
is_valid
</a>
)
</li>
<li><span
class=
"parameter"
>
name
</span>
<span
class=
"types"
><a
class=
"type"
href=
"http://www.lua.org/manual/5.1/manual.html#5.4"
>
string
</a></span>
</li>
</ul>
<h3>
Returns:
</h3>
<ol>
<li>
<span
class=
"types"
><a
class=
"type"
href=
"http://www.lua.org/manual/5.1/manual.html#5.4"
>
string
</a></span>
<code>
uuid
</code>
: a v5 (namespaced) UUID.
</li>
<li>
<span
class=
"types"
><a
class=
"type"
href=
"http://www.lua.org/manual/5.1/manual.html#5.4"
>
string
</a></span>
<code>
err
</code>
: a string describing an error
</li>
</ol>
<h3>
Usage:
</h3>
<ul>
<pre
class=
"example"
>
<span
class=
"keyword"
>
local
</span>
uuid =
<span
class=
"global"
>
require
</span>
<span
class=
"string"
>
'resty.jit-uuid'
</span>
<span
class=
"keyword"
>
local
</span>
u = uuid.generate_v5(
<span
class=
"string"
>
'e6ebd542-06ae-11e6-8e82-bba81706b27d'
</span>
,
<span
class=
"string"
>
'hello'
</span>
)
---
>
<span
class=
"number"
>
4850816
</span>
f-
<span
class=
"number"
>
1658
</span>
-
<span
class=
"number"
>
5890
</span>
-
<span
class=
"number"
>
8
</span>
bfd-
<span
class=
"number"
>
1
</span>
ed14251f1f0
</pre>
</ul>
</dd>
</dl>
...
...
@@ -295,7 +400,7 @@
</div>
<!-- id="main" -->
<div
id=
"about"
>
<i>
generated by
<a
href=
"http://github.com/stevedonovan/LDoc"
>
LDoc 1.4.3
</a></i>
<i
style=
"float:right;"
>
Last updated 2016-0
4-20 17:47:16
</i>
<i
style=
"float:right;"
>
Last updated 2016-0
5-09 10:26:07
</i>
</div>
<!-- id="about" -->
</div>
<!-- id="container" -->
</body>
...
...
lib/resty/jit-uuid.lua
浏览文件 @
3a2fae8b
...
...
@@ -3,7 +3,7 @@
-- @module jit-uuid
-- @author Thibault Charbonnier
-- @license MIT
-- @release 0.0.
3
-- @release 0.0.
4
local
bit
=
require
'bit'
local
tohex
=
bit
.
tohex
...
...
@@ -184,10 +184,9 @@ do
end
end
---
Gener
ate a v3 UUID factory.
---
Instanci
ate a v3 UUID factory.
-- @function factory_v3
-- Creates a closure generating namespaced v3 UUIDs.
--
-- @param[type=string] namespace (must be a valid UUID according to `is_valid`)
-- @treturn function `factory`: a v3 UUID generator.
-- @treturn string `err`: a string describing an error
...
...
@@ -216,10 +215,9 @@ do
end
end
---
Gener
ate a v5 UUID factory.
---
Instanci
ate a v5 UUID factory.
-- @function factory_v5
-- Creates a closure generating namespaced v5 UUIDs.
--
-- @param[type=string] namespace (must be a valid UUID according to `is_valid`)
-- @treturn function `factory`: a v5 UUID generator.
-- @treturn string `err`: a string describing an error
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录