在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):thibaultcha/lua-resty-jit-uuid开源软件地址(OpenSource Url):https://github.com/thibaultcha/lua-resty-jit-uuid开源编程语言(OpenSource Language):Perl 51.1%开源软件介绍(OpenSource Introduction):lua-resty-jit-uuidA pure LuaJIT (no dependencies) UUID library tuned for performance. Table of ContentsMotivationThis module is aimed at being a free of dependencies, performant and complete UUID library for LuaJIT and ngx_lua. Unlike FFI and C bindings, it does not depend on libuuid being available in your system. On top of that, it performs better than most (all?) of the generators it was benchmarked against, FFI bindings included. Finally, it provides additional features such as UUID v3/v4/v5 generation and UUID validation. See the Benchmarks section for comparisons between other UUID libraries for Lua/LuaJIT. UsageLuaJIT: local uuid = require 'resty.jit-uuid'
uuid.seed() ---> automatic seeding with os.time(), LuaSocket, or ngx.time()
uuid() ---> v4 UUID (random)
uuid.generate_v4() ---> v4 UUID
uuid.generate_v3() ---> v3 UUID (name-based with MD5)
uuid.generate_v5() ---> v5 UUID (name-based with SHA-1)
uuid.is_valid() ---> true/false (automatic JIT PCRE or Lua patterns) OpenResty: http {
init_worker_by_lua_block {
local uuid = require 'resty.jit-uuid'
uuid.seed() -- very important!
}
server {
location / {
content_by_lua_block {
local uuid = require 'resty.jit-uuid'
ngx.say(uuid())
}
}
}
} Note: when generating v4 (random) UUIDs in ngx_lua, it is very
important that you seed this module in the InstallationThis module can be installed through Luarocks: $ luarocks install lua-resty-jit-uuid Or via opm: $ opm get thibaultcha/lua-resty-jit-uuid Or can be manually copied in your DocumentationDocumentation is available online at http://thibaultcha.github.io/lua-resty-jit-uuid/. BenchmarksThis module has been carefully benchmarked on each step of its implementation to ensure the best performance for OpenResty and plain LuaJIT. For example, UUID validation will use JIT PCRE over Lua patterns when possible. The Run
Note: UUID validation performance in ngx_lua (JIT PCRE) can be greatly improved by enabling lua-resty-core. ContributionsSuggestions improving this module's or the benchmarks' performance (of any benchmarked library) are particularly appreciated. LicenseWork licensed under the MIT License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论