UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'dR7n+1bJmYUFbQnYvpF1DiurAI4Euz7YdFbT8dvFfhM='
WHERE
key_id = '647ffb28c0912f8264a66ffabf1cfc1aeafb48e3ce6e15a028ff4690df2b2553'
AND (
token = 'dR7n+1bJmYUFbQnYvpF1DiurAI4Euz7YdFbT8dvFfhM='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)