UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ZqLLl6tyv1o3Bj+GtJ8eHlXhlPQ6QD9Hve4pWrfUnIs=' 
WHERE 
  key_id = '12f14ee459cc28bb0384bb21670a0b20cf8f7525087948e09cedfd04f8dad1f3' 
  AND (
    token = 'ZqLLl6tyv1o3Bj+GtJ8eHlXhlPQ6QD9Hve4pWrfUnIs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024