Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hqzxzb/lua-resty-unique-id
Lua library for generating a unique ID for OpenResty
https://github.com/hqzxzb/lua-resty-unique-id
Last synced: 2 months ago
JSON representation
Lua library for generating a unique ID for OpenResty
- Host: GitHub
- URL: https://github.com/hqzxzb/lua-resty-unique-id
- Owner: hqzxzb
- License: apache-2.0
- Created: 2018-04-16T12:35:49.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-16T13:06:39.000Z (almost 7 years ago)
- Last Synced: 2024-02-15T01:34:48.024Z (12 months ago)
- Language: Lua
- Size: 13.7 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-resty - lua-resty-unique-id
README
# lua-resty-unique-id
Lua library for generating a unique ID for OpenResty# Description
This Lua library is a unique ID generator in OpenResty.
You can use it to generate a unique ID that will not be duplicated for your OpenResty.
# The Unique ID pattern generated by this library
(13-bit millisecond-level timestamp)-(12-bit IP address)-(6-bit Nginx Worker PID)-(3 bit Nginx Worker number)-(6-bit auto-increasing random number)
E.g : ```1523881864432-010020100149-087846-000-005964```
# How to use
1. Perform initialization in ```init_by_lua``` or ```init_by_lua_file``` :
```lua
--Load Unique ID library and initialize
require("unique_id");
unique_id.init();
```2. Use Unique ID library in your Lua script :
```lua
local id = unique_id.id();
```# Test Results
> Test using Apache httpd ab tool
---
**Windows**
**200000** requests and **500** concurrent
**No duplicate value.**
---
**Linux**
**200000** requests and **500** concurrent
**No duplicate value.**