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