CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • AttributeResolver
    • Cache
    • Collection
    • Command
    • Console
    • Container
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Namespace Lock

Namespaces

  • Cake\Lock\Engine
  • Cake\Lock\Exception

Interfaces

  • LockInterface

    Interface for lock engines.

    Lock engines provide distributed locking mechanisms to prevent race conditions when multiple processes access shared resources.

Classes

  • AcquiredLock

    Represents an acquired lock.

  • Lock

    Lock provides a consistent interface to distributed locking.

    Configuring Lock engines

    You can configure Lock engines in your application's bootstrap:

    Lock::setConfig('default', [
       'className' => \Cake\Lock\Engine\RedisLockEngine::class,
       'host' => '127.0.0.1',
       'port' => 6379,
    ]);

    Usage examples

    Prefer synchronized() when you can, as it guarantees prompt release:

    $result = Lock::synchronized('my-resource', function () {
        // Critical section
        return $computedValue;
    });

    Acquiring and releasing a lock:

    $lock = Lock::acquire('my-resource');
    if ($lock !== null) {
        try {
            // Critical section
        } finally {
            $lock->release();
        }
    }
  • LockEngine

    Abstract base class for lock engines.

    Provides common functionality for all lock engine implementations, including configuration management and key generation.

  • LockRegistry

    Registry for lock engines.

    Used by {@link \Cake\Lock\Lock} to manage lock engine instances.

OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs