UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '6PYZJ9BkpYxKSP8B9nfu9cPguQI7bmiKNo72E8UnflM='
WHERE
key_id = 'f9875e41f4fcb71457a6fb8e242fd17fbd3e123e6b93f971708e392bdeaf0f0a'
AND (
token = '6PYZJ9BkpYxKSP8B9nfu9cPguQI7bmiKNo72E8UnflM='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)