getLockFactory(); $lock = $factory->createLock($actionId); $lock->acquire(true); sleep($sleep); $lock->release(); /** * @param $class * @param $dir * @return LockService * @throws common_Exception */ function getInstance($class, $dir) { $config = new \common_persistence_KeyValuePersistence([], new \common_persistence_InMemoryKvDriver()); $config->set(\common_persistence_Manager::SERVICE_ID, new \common_persistence_Manager()); $serviceManager = new ServiceManager($config); $service = new LockService([ LockService::OPTION_PERSISTENCE_CLASS => $class, LockService::OPTION_PERSISTENCE_OPTIONS => $dir ]); $service->setServiceLocator($serviceManager); return $service; }