Lock Service¶
Meaning of Lock¶
Lock service is a functionality that does the unique locking for entire intra-mart system.It is used for disabling the specific functionality or when serialization of processes is to be done.Note
Lock usage status can be checked by [System administrator] – [Application lock list] screen.Refer system administrator operations guide for the details.
Sample program¶
Execute the process logic after locking. Implement the following to release the lock.(In this sample, throw an exception when it is not locked within 5 seconds)// Lock var lockId = "lock_key"; if (!NewLock.tryLock(lockId, 5)) { // Failed in lock return false; } //Proceessing Logic //Release Lock if (!NewLock.unlock(lockId)) { // Failed in release lock return false; }
Lock Linked With Request¶
Use the following methods to start the lock which is linked with request.NewLock.tryLockRequestScope(lockId, 5);The lock using this function is auto-released when returning the response.Moreover, by using unlock () function, lock can be released any time.Lock using this function in order to avoid omission of lock release.Warning
This function cannot be used in asynchronous tasks or in the processing of job executed by jobscheduler, since lock is linked with the request and it is auto released.