Code Monkey home page Code Monkey logo

dbs-lock's Introduction

description

This module support for redis and dynamodb database. It is use to lock one data using aquire_lock() function and release the lock by release_lock() function. it is support the timeout for the lock to both database. The parameter of the timeout it different for redis use time in seconds and dynamodb use timestamp in seconds. when you call the init method pass the Database url and the Database name

Redis Lock

var db_lock= require('<module name>')
async function test (){
   let dbconection = await db_lock.init("< redis connection url >", "redis")

   await dbconection.aquire_lock("<KEY>","<time out in seconds>","<KEY VAlUE>");
   await dbconection.release_lock("<KEY>")
}

Dynamodb lock

BY default this module create a table.if you want to use specify customs table create the enviroment variable LOCK_TABLE . In the customs table only have the primary key which is LockName and enable the Time to live attribute on ttl refer this link

 var db_lock= require('<module name>')
 async function test (){
    let dbconection = await db_lock.init("<db connection url>", "dynamodb")

    await dbconection.aquire_lock("<KEY>","<time out in timestamp in seconds>","<KEY VAlUE>");
    await dbconection.release_lock("<KEY>")


 }

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.