UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'x8QgzD4BtWZtOZoi9/CfNYq61LzjTB37ujLsPJBu9w8='
WHERE
key_id = '4ba286c3b5e3bd675ec544599a9c699c02ea565439f8afd3244b751203abe4d3'
AND (
token = 'x8QgzD4BtWZtOZoi9/CfNYq61LzjTB37ujLsPJBu9w8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)