Code Monkey home page Code Monkey logo

lua-resty-unique-id's Introduction

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 :
--Load Unique ID library and initialize
require("unique_id");
unique_id.init();
  1. Use Unique ID library in your Lua script :
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.

lua-resty-unique-id's People

Contributors

hqzxzb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.