Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6250823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:29:58+00:00 2026-05-24T13:29:58+00:00

I am developing a record storage system which stores scanned, indexed and encrypted records

  • 0

I am developing a record storage system which stores scanned, indexed and encrypted records in physical boxes.

I have a method say “getAvailablePlace()” which checks what box and what seq is available for store. I want to lock this method. Ie when one user is entered into this method and he gets box:12 seq:55 as empty place..simultaneously at same time another user is accessing same method he may also get same values..box:12 seq:55 which is error prone.

So if I can lock this method when one user is already into this process?

I am using SQLite, wamp and codeigniter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:29:59+00:00Added an answer on May 24, 2026 at 1:29 pm

    I have this code in use:

    define('LOCK_FILE', "/path/to/your/lockfile-".$argv[1].".lock");
    if( isLocked() ) die("ALREADY RUNNING !!!!\n" );
    
    function isLocked()
    {
        # If lock file exists, check if stale.  If exists and is not stale, return TRUE
        # Else, create lock file and return FALSE.
    
        if( file_exists( LOCK_FILE ) )
        {
            # check if it's stale
            $lockingPID = trim( file_get_contents( LOCK_FILE ) );
    
           # Get all active PIDs.
            $pids = explode( "\n", trim( `ps -e | awk '{print $1}'` ) );
    
            # If PID is still active, return true
            if( in_array( $lockingPID, $pids ) )  return true;
    
            # Lock-file is stale, so kill it.  Then move on to re-creating it.
            echo "Removing stale lock file.\n";
            unlink( LOCK_FILE );
        }
    
        file_put_contents( LOCK_FILE, getmypid() . "\n" );
        return false;
    } 
    

    You may alter it not to check the pid and just use the file as lock info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am developing an application in which i have to record compass reading. which
I am developing an application in which I want to record the sound of
i am developing an application in which i am trying to record a video
I'm currently developing a C# application which will record registry changes, save them to
I am developing an application in which I want to record communication of incoming
I am developing an application in which I have to perform three functions play,
I'm developing a PHP/MYSQL powered system, and have facebook, twitter and normal login. Each
I'm developing a medical record system for iOS and OSX. The idea is to
We're in process of developing a desktop application which needs to record user's screen
I am developing web app using Scala and Lift framework. I have record in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.