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 5.4 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.4
      • 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
    • Cache
    • Collection
    • Command
    • Console
    • Container
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
      • Engine
      • Exception
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class AcquiredLock

Represents an acquired lock.

Namespace: Cake\Lock

Property Summary

  • $released protected
    bool

    Whether the lock has already been released.

Method Summary

  • __construct() public

    Constructor.

  • __destruct() public

    Attempt to release the lock when it falls out of scope.

  • getAcquiredAt() public

    Get the timestamp when the lock was acquired.

  • getRemainingTtl() public

    Get remaining time until expiration in seconds.

  • getResource() public

    Get the locked resource identifier.

  • getToken() public

    Get the unique token identifying the lock owner.

  • getTtl() public

    Get the time-to-live in seconds.

  • isExpired() public

    Check if the lock has expired based on its TTL.

  • isReleased() public

    Check whether the lock has already been released.

  • refresh() public

    Refresh the lock with the engine that acquired it.

  • release() public

    Release the lock with the engine that acquired it.

Method Detail

__construct() ¶ public

__construct(string $resource, string $token, int $ttl, float $acquiredAt, Cake\Lock\LockInterface|null $engine = null)

Constructor.

Parameters
string $resource

The locked resource identifier.

string $token

Unique token identifying the lock owner.

int $ttl

Time-to-live in seconds.

float $acquiredAt

Timestamp when the lock was acquired.

Cake\Lock\LockInterface|null $engine optional

The engine that acquired the lock.

__destruct() ¶ public

__destruct()

Attempt to release the lock when it falls out of scope.

getAcquiredAt() ¶ public

getAcquiredAt(): float

Get the timestamp when the lock was acquired.

Returns
float

getRemainingTtl() ¶ public

getRemainingTtl(): float

Get remaining time until expiration in seconds.

Returns
float

Remaining seconds, may be negative if expired.

getResource() ¶ public

getResource(): string

Get the locked resource identifier.

Returns
string

getToken() ¶ public

getToken(): string

Get the unique token identifying the lock owner.

This token is used to verify ownership when releasing or refreshing the lock.

Returns
string

getTtl() ¶ public

getTtl(): int

Get the time-to-live in seconds.

Returns
int

isExpired() ¶ public

isExpired(): bool

Check if the lock has expired based on its TTL.

Note: This is a local check based on the original TTL. The actual lock state in the backend may differ due to clock skew or manual intervention.

Returns
bool

True if the lock has likely expired.

isReleased() ¶ public

isReleased(): bool

Check whether the lock has already been released.

Returns
bool

refresh() ¶ public

refresh(int|null $ttl = null): bool

Refresh the lock with the engine that acquired it.

Parameters
int|null $ttl optional

New TTL in seconds. If null, uses the original TTL.

Returns
bool

True if the lock was refreshed, false otherwise.

release() ¶ public

release(): bool

Release the lock with the engine that acquired it.

Returns
bool

True if the lock was released, false otherwise.

Property Detail

$released ¶ protected

Whether the lock has already been released.

Type
bool
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