UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'sN7ZUf9wTim8ayivZm4uITyZ2d50T0orkdSOjuCH1do='
WHERE
key_id = 'c15859e91f46c4200eda305cec92b5e15679efed4534beb32c7c0acaffac9630'
AND (
token = 'sN7ZUf9wTim8ayivZm4uITyZ2d50T0orkdSOjuCH1do='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)