UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Z4PVbQKafKnZmGhmBacmV12o8WUv563f/apACOniRfE=' 
WHERE 
  key_id = '9ea7daca7780f62473590f735452f9715be03d349e9cd13fc12b02e574ac8a9a' 
  AND (
    token = 'Z4PVbQKafKnZmGhmBacmV12o8WUv563f/apACOniRfE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00042