UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'C5gYImAuMhm/loGUHb5Kq7gAK8qR9mvTCEJX4WImz8Y=' 
WHERE 
  key_id = 'ee4f23a16470dfd1259002595c6da0571e66cca653b55df312265fedc2084047' 
  AND (
    token = 'C5gYImAuMhm/loGUHb5Kq7gAK8qR9mvTCEJX4WImz8Y=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00036